I have searched for a while and tried a couple solutions like creating a separate function.
the way my code works is the local script fires the server with a string, and then the server uses that string to decide which animation its gonna play (slash, idle, etc) here is my code
Server:
local rem = script.Parent:WaitForChild("RemoteEvent")
rem.OnServerEvent:Connect(function(player, stringe)
if stringe == "Idle" then
local hum = player.Character.Humanoid
local animator = hum.Animator
local animation = game.ServerStorage.Animations.IdlePin
local animationPlay = animator:LoadAnimation(animation)
animationPlay:Play()
elseif stringe == "IdleUnequip" then
local hum = player.Character.Humanoid
local animator = hum.Animator
local animation = game.ServerStorage.Animations.IdlePin
local track = animator:LoadAnimation(animation)
track:Stop()
end
end)
Local:
local equipped = false
local stringe
local rem = script.Parent:WaitForChild("RemoteEvent")
script.Parent.Equipped:Connect(function()
stringe = "Idle"
rem:FireServer(stringe)
equipped = true
end)
script.Parent.Unequipped:Connect(function()
stringe = "IdleUnequip"
rem:FireServer(stringe)
equipped = false
end)
