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

My animation is working in Studio, but not in the actual game?

Asked by 4 years ago

Hello! I have coffee in my game. In the cup tool I have an animation script. When you click the screen with the tool in your hand, it plays the animation. This works perfectly in Studio, but not in the game. Also, it works in another tool I have, in game and Studio. I just copied the script from that to the cup tool. Here is the script if you need it:

local Tool = script.Parent
local humanoid = nil
local drinker = nil
local con = nil
local enabled = false

function onEquipped(mouse)

    if (Tool.Name == "Cappuccino") then

    Tool.Handle.OpenSound:play()
    humanoid = Tool.Parent:FindFirstChild("Humanoid")
    if humanoid ~= nil then
        drinker = humanoid:LoadAnimation(Tool.Eat)
    end
    con = mouse.Button1Down:connect(function() onButton1Down(mouse) end)

end

function onUnequipped(mouse)

    humanoid = nil
    if drinker ~= nil then
        drinker:remove()
        drinker = nil
    end
    if con ~= nil then
        con:disconnect()
    end

end

function onButton1Down(mouse)

    if enabled then
        return
    end

    enabled = true 


    drinker:Play()
    Tool.Handle.DrinkSound:Play()
    wait(3)

    enabled = false


end
end

Tool.Equipped:connect(onEquipped)
Tool.Unequipped:connect(onUnequipped)

0
if this is a server script, try converting it to a LocalScript Mayk728 855 — 4y
0
I agree. Try changing it to a LocalScript. Geobloxia 251 — 4y
0
It is a local script. The other tool works which has exactly the same script. OrbitOps 34 — 4y

Answer this question