I have a knife animation in a tool, it plays on my screen in studio, but not on my friends screen in studio. I’m wondering how to fix this? here is the script:
local tool = script.Parent
local cooldown = script.cooldown.Value
cooldown = false
local Activated = false
tool.Activated:Connect(function()
local humanoid = tool.Parent:FindFirstChildWhichIsA('Humanoid')
local animation =script.swing
if humanoid and cooldown == false then
Activated = true
cooldown = true
local playanim = humanoid:LoadAnimation(animation)
playanim:Play()
wait(2)
playanim:Stop()
wait(2)
cooldown = false
Activated = false
end
end)
script.Parent.Activated:Connect(function()
end)
script.Parent["knife part 2"].TouchEnded:Connect(function(BasePart)
if BasePart.Parent.Parent.Name == "ZombieFolder" then
if Activated then
BasePart.Parent.Humanoid.Health -= script.Parent:GetAttribute("Damage")
end
end
end)
Make the animation play when a remote event has beened called
Current script your using
local tool = script.Parent
local cooldown = script.cooldown.Value
cooldown = false
local Activated = false
tool.Activated:Connect(function()
local humanoid = tool.Parent:FindFirstChildWhichIsA('Humanoid')
local animation =script.swing
if humanoid and cooldown == false then
Activated = true
cooldown = true
remotiveEvent:FireServer()
cooldown = false
Activated = false
end
end)
script.Parent.Activated:Connect(function()
Server script
remoteEvent.OnServerEvent:Connect(function(player)
local humanoid = player.Character.Humanoid
if humanoid:FindFirstChild("Animator") then
if humanoid.Animator:FindFirstChild(ANIMTION) then
animtion:Play()
else
local knifeAnim = animator:LoadAnimation(ANIMATION)
knifeAnim:Play()
else
local animator = Instance.new("Animator")
animator.Parent = humanoid
local knifeAnim = animator:LoadAnimation(ANIMATION)
knifeAnim:Play()
then
The animation has to be played in a server script, try this.
local tool script:
local tool = script.Parent
local cooldown = script.cooldown.Value
cooldown = false
local Activated = false
tool.Activated:Connect(function()
local humanoid = tool.Parent:FindFirstChildWhichIsA('Humanoid')
local animation =script.swing
if humanoid and cooldown == false then
Activated = true
cooldown = true
local playanim = humanoid:LoadAnimation(animation)
RemoteEvent:FireServer(playanim, "Start") -- put your remote event here
wait(2)
RemoteEvent:FireServer(playanim, "End") -- put your remote event here (same remote event)
wait(2)
cooldown = false
Activated = false
end
end)
script.Parent.Activated:Connect(function()
end)
script.Parent["knife part 2"].TouchEnded:Connect(function(BasePart)
if BasePart.Parent.Parent.Name == "ZombieFolder" then
if Activated then
BasePart.Parent.Humanoid.Health -= script.Parent:GetAttribute("Damage")
end
end
end)
server script:
RemoteEvent.OnServerEvent:Connect(function(Player, Anim, Status)
if Status == "Start" then
Anim:Play()
end
if Status == "End" then
Anim:Stop()
end
end)
Character animations should be played on the client, the issue likely stems from animation ownership (an animation must be uploaded by a user/group in order for that animation to be played in that user’s/group’s games).
Exploiters can still set off remote events. The code mentioned above doesn’t use server side checking so exploiters can still do the same thing. If server side checking is used, it is fine I guess.
My knife script is on client, my damage and animation scripts are on server, but the animation still plays for me, but not my friends. I have no errors in the output. Does anybody know why this might be happening?