Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

equip animation for Gun not Working. Help?

i have a lot of trouble with remote events, and i'm making a equip animation for a gun, can you guys correct me pls??

local player = game:GetService("Players").LocalPlayer
local equip_anima = script.Parent:WaitForChild("Equip")
equip_anima.OnServerEvent:Connect(function()
	local animaequip = equip_anima:WaitForChild("Equiping")
	local animaequiptrack = player.Character:WaitForChild("Humanoid"):LoadAnimation(animaequip)
	animaequiptrack:Play()
end)

2 comments

0

i dont see anywhere where "player" is defined. it should be the parameter of "OnServerEvent". it wouldnt hurt to make better variable names either!

0

just putting this out there for you, but the whole point of variables is so that you can assign a long line of code or something to a short variable. So what that means is don't make a variable name that is almost as long as the line of code you're trying to simplify.

1 answer

✓ Accepted answer

If this is an animation for a thing such as a tool, for example, you don't need to use RemoteEvents to play an animation client-sided. Below, is a simplified client-sided animation player:

local player = game:GetService("Players").LocalPlayer
local equipAnim = script.Parent:WaitForChild("Equip"):WaitForChild("Equiping")

local equipTrack = player.Character:WaitForChild("Humanoid"):LoadAnimation(equipAnim)
equipTrack:Play()

If you need any other help, just reply to this answer. :)

-Crystal

This discussion is preserved as it was. New answers, comments, and votes are closed.