I'm trying to create a speed potion with an animation I have made with Animation Editor (R15). However, I think I may have done something wrong with the script,
local CanActivate = true local player = game.Players.LocalPlayer local character = player.Character script.Parent.Activated:connect(function() if CanActivate = true then local animation = character.Humanoid:LoadAnimation(script.Parent.ZTZ) animation:Play() end end)
The animation's name is ZTZ if your wondering what that's about. Also im very new to scripting so I may have made a stupid mistake. Any help would be greatly appreciated! :)
Okay, so all you have to do is change the "script", to "LocalScript", then try putting in this code I've been working on inside the local script (it's a revised of your script but fixed i guess, i mean i'm not perfect, but it is working for me, instead of using your animation "since i do not know it", I used my own animation and found the test successful in studio.)
local Tool = script.Parent local humanoid = nil local connection = nil local playing = false activated = nil local CanActivate = true local player = game.Players.LocalPlayer local character = player.Character function onEquippedLocal(mouse) humanoid = Tool.Parent:FindFirstChild("Humanoid") activated = humanoid:LoadAnimation(Tool.ZTZ) connection = mouse.Button1Down:connect(activatedd) end function onUnequippedLocal() humanoid = nil if activated ~= nil then activated:Stop() activated:remove() activated = nil end connection:disconnect() end function activatedd() if playing then return end playing = true if CanActivate == true then local animation = character.Humanoid:LoadAnimation(script.Parent.ZTZ) animation:Play() wait(10)--Change it to how long your animation is going to run animation:Stop()--If your animation is a loop, you're going to need this playing = false end end Tool.Equipped:connect(onEquippedLocal) Tool.Unequipped:connect(onUnequippedLocal)
local CanActivate = false local ply = game.Players.LocalPlayer local character = ply.Character local m = ply:GetMouse() script.Parent.Activated:connect(function() CanActivate = true end) script.Parent.Deactivate:connect(function() CanActivate = false end) m.Button1Down:connect(function() if CanActivate == true then local animation = character.Humanoid:LoadAnimation(script.Parent.ZTZ) animation:Play() end end)