local plr = game.Players.LocalPlayer local event = script.Parent.RemoteEvent local gunMod = script.Parent.Parent["gun model excluding the handle.......obviously"] local tool = script.Parent.Parent local holdAnim = script.Parent.Hold tool.Equipped:Connect(function() local animator wait(0.2) local humanoid = script.Parent.Parent.Parent:WaitForChild("Humanoid") print(humanoid) print(humanoid.Parent) if humanoid ~= nil then animator = Instance.new("Animator",humanoid) animator.Parent = humanoid end holdAnim.Parent = humanoid local Animater = humanoid:WaitForChild("Animator") local loadedAnim = Animater:LoadAnimation(holdAnim) loadedAnim:Play() print("H") end)
This is on a Server Script . What happens: https://gyazo.com/178fd7dc5d1027c5bcb309228055e64e Please help me bustaronies ! There are NO errors in output
Also I just want to thank this Site because I probably wouldnt be coding if it didnt push me to start, thanks to everybody who responed to all my threads, I greatly appreciate you. Anybody can learn LUA
Problem
I'm pretty sure all you need to do is loop the animation and set the animation priority to Action(Max priority). Setting it to the Action priority will override all animations that have an animation priority below the Action priority.
You don't need to create the Animator, it's already there, but you can't see it.
Recommendations
You should avoid using wait(n)
Waiting for events to be fired is a better solution than wait(n)
for example, RunService.Heartbeat:Wait()
is better. Using wait(n)
or wait() can decrease the performance of your game. If you want more information on avoiding waits, you can look here.
It's a bad practice to create a new Instance and instantly parent it. You should change all the property first, then the last thing you do is parent it. Doing this can increase performance.
Fixed code
local plr = game.Players.LocalPlayer local event = script.Parent.RemoteEvent local gunMod = script.Parent.Parent["gun model excluding the handle.......obviously"] local tool = script.Parent.Parent local holdAnim = script.Parent.Hold tool.Equipped:Connect(function() local humanoid = script.Parent.Parent.Parent:WaitForChild("Humanoid") if humanoid then local Animator = humanoid:WaitForChild("Animator") local loadedAnim = Animator:LoadAnimation(holdAnim) loadedAnim.Looped = true loadedAnim.Priority = Enum.AnimationPriority.Action loadedAnim:Play() end end)
Hopefully, this should work because I wrote the code here and not in Roblox Studio.