Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Animation runs on studio but not on the actual game?

Asked by 4 years ago

The title shows my issue, any help would be great, thanks!

01Mouse.Button1Up:Connect(function()
02    if not AnimationDebounce then
03        if game.Players.LocalPlayer.Character:FindFirstChildOfClass("Tool") and script.Parent.BoolValue.Value == true and Equip == true then
04            if script.Parent:FindFirstChild("SelectionBox") then
05                script.Parent.SelectionBox:Destroy()
06            end
07            local Tool = script.Parent
08            if Tool.Parent == game.Players.LocalPlayer.Character then
09            if Tool:FindFirstChild("DrinkPart") then
10            AnimationDebounce = true
11            if game.Players.LocalPlayer.Character:FindFirstChild("Torso") then
12                        if Equip == true then
13                            script.Parent.RemoteEvent:FireServer()
14                            Animation:Play()
15                wait(3)
View all 23 lines...

1 answer

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

If the animations weren't made by you or Roblox, they will not show up. But the reason this is not working is because the code you're using is highly inefficient.

Add a bool value inside of the tool called "cooldown" and set the value to false.

Possible fix:

01local tool = script.Parent
02local animation = script.Animation
03local cooldown = script.Parent.Cooldown
04 
05tool.Equipped:Connect(function()
06        wait(1) -- Waits to prevent lag
07    local humanoid = tool.Parent:FindFirstChildWhichIsA('Humanoid')
08    if humanoid and cooldown == false then
09        cooldown = true
10        local playanim = humanoid:LoadAnimation(animation)
11        playanim:Play()
12        tool.Handle.Damage.Disabled = false
13        wait(0.7)
14        playanim:Stop()
15        tool.Handle.Damage.Disabled = true
16        wait(0.5)
17        cooldown = false
18    end
19end)
Ad

Answer this question