adicione a funaço de dar player num sound no soundservice quando  a animaçao for tocada : local player = game.Players.LocalPlayer
local TextBox = script.Parent -- Adjust this if the script isn't a direct child of the TextBox

-- Replace "AnimationIDHere" with your actual animation ID
local animationId = "rbxassetid://131028936257839"
local Animation = Instance.new("Animation")
Animation.AnimationId = animationId

-- Variables to manage animation and input
local animationTrack
local keysPressed = 0 -- Counter for keys currently pressed (PC)
local debounce = false
local isAnimationPlaying = false

local RunService = game:GetService("RunService")
local lastTextChangeTime = nil
local typingStopDelay = 0.75 -- Time after which we consider typing has stopped (mobile)

-- RemoteEvent for accessory management
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local AccessoryEvent = ReplicatedStorage:WaitForChild("AccessoryEvent")
local lastAccessoryEventTime = 0
local accessoryEventCooldown = 0.5 -- Send typing notification at most every 0.5 seconds

local function playAnimation()
	if not isAnimationPlaying then
		-- Play the animation
		local character = player.Character or player.CharacterAdded:Wait()
		local humanoid = character:FindFirstChildOfClass("Humanoid")
		if humanoid then
			animationTrack = humanoid:LoadAnimation(Animation)
			animationTrack:Play()
			isAnimationPlaying = true
		end
	end
end

local function stopAnimation()
	if isAnimationPlaying and animationTrack then
		animationTrack:Stop()
		isAnimationPlaying = false
	end
end

-- Function to handle input began in the TextBox (for PC)
local function onInputBegan(input)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		keysPressed = keysPressed + 1
		if not debounce then
			debounce = true
			playAnimation()

			-- Send typing notification to server with cooldown
			if tick() - lastAccessoryEventTime >= accessoryEventCooldown then
				AccessoryEvent:FireServer("Typing")
				lastAccessoryEventTime = tick()
			end

			-- Debounce timer of 0.1 seconds
			task.delay(0.75, function()
				debounce = false
			end)
		end
	end
end

-- Function to handle input ended in the TextBox (for PC)
local function onInputEnded(input)
	if input.UserInputType == Enum.UserInputType.Keyboard then
		keysPressed = math.max(keysPressed - 1, 0)
		if keysPressed == 0 then
			stopAnimation()
		end
	end
end

-- Connect for keyboard input in the TextBox (for PC)
TextBox.InputBegan:Connect(onInputBegan)
TextBox.InputEnded:Connect(onInputEnded)

-- Connect to Text changes in the TextBox (for mobile)
TextBox:GetPropertyChangedSignal("Text"):Connect(function()
	if TextBox:IsFocused() then
		lastTextChangeTime = tick()
		if not isAnimationPlaying then
			playAnimation()
		end

		-- Send typing notification to server with cooldown
		if tick() - lastAccessoryEventTime >= accessoryEventCooldown then
			AccessoryEvent:FireServer("Typing")
			lastAccessoryEventTime = tick()
		end
	end
end)

-- Use Heartbeat to check for typing stop on mobile
RunService.Heartbeat:Connect(function(step)
	if lastTextChangeTime and (tick() - lastTextChangeTime) >= typingStopDelay then
		stopAnimation()
		lastTextChangeTime = nil
	end
end)

-- Also handle focus lost to stop the animation
TextBox.FocusLost:Connect(function()
	stopAnimation()
	lastTextChangeTime = nil
	keysPressed = 0
end)