Hey, lately I made this code, but it doesn’t work it meant to be a button which launches a emote.
Code:
"local btn = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild(“Humanoid”,10)
local CanEmote = true
local CoolDown = 0
btn.MouseButton1Click:connect(function()
if CanEmote == true then
CanEmote = true
local dance = hum:LoadAnimation(script:FindFirstChild(“Anim1”))
dance:Play()
So I had made this code for night club:
local btn = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild(“Humanoid”,10)
local CanEmote = true
local CoolDown = 0
btn.MouseButton1Click:connect(function()
if CanEmote == true then
CanEmote = true
local dance = hum:LoadAnimation(script:FindFirstChild(“Anim1”))
dance:Play()
end
end)
As it lauches dances, but it doesn’t work actually.
local btn = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild(“Humanoid”,10)
local CanEmote = true
local CoolDown = 0
btn.MouseButton1Click:connect(function()
if CanEmote == true then
CanEmote = true
local dance = hum:LoadAnimation(script:FindFirstChild(“Anim1”))
dance.Priority=Enum.AnimationPriority.Action
dance:Play()
end
end)
I’m not sure this is on topic, but a snippet in your code is
if CanEmote == true then
CanEmote = true
I was wondering why the script is setting CanEmote to true after it is already set to true.
Also, if the cooldown isn’t working, you could try this:
btn.MouseButton1Down:Connect(function()
if CanEmote then
CanEmote = false
local Dance = hum:LoadAnimation(script.Anim1)
Dance.Priority = Enum.AnimationPriority.Action
Dance:Play()
wait(Dance.Length) -- will wait until the animation finishes playing
CanEmote = true -- The player can use the emote again after it has done playing
end
end)
This ie not helpful. For us to help you (which you want) you have to help us. What is the problem? Are there any errors? What is your current code? What is your goal?
Seeing as the CanEmote is not being set to false, I see one issue.
You aren’t able to stop the debounce.
local btn = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild(“Humanoid”, 1)
local CanEmote = true
btn.Activated:Connect(function()
if CanEmote then
CanEmote = false
local dance = hum:LoadAnimation(script:FindFirstChild(“Anim1”))
dance:Play()
dance.Stopped:Wait()
CanEmote = true
end
end)
Hopefully this solves your issue.
Also, please use ``` so your text is formatted in code.
Alrightly, so I a trying to make animation GUI, like when there is a click on it, you should start the emote. Yes there is a error, here: Players.teddyHV11.PlayerGui.ScreenGui.Dances.Wave.LocalScript:4: unescpected symbol near ' '
local btn = script.Parent
local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:Wait()
local hum = char:WaitForChild(“Humanoid”,10)
local CanEmote = true
local CoolDown = 0
local dance = hum:LoadAnimation(script:FindFirstChild(“Anim1”))
btn.MouseButton1Click:connect(function()
if CanEmote == true then
wait(dance.length)
dance:Stop()
end)
Hope i helped! @teddyHV11 , make sure this is a local script inside button
connect is deprecated, use Connect instead. The script itself won’t work as line 11 if else statement doesn’t have a end to it, and you never actually play the animation in that script. And the line 11 statement is useless as the debounce is never used. Sorry if this comes off as attacking! I won’t provide the correct code here as here is already the correct code and the question is solved.