In ServerStorage, I have a tool (its a sunscreen bottle) and inside i have 2 scripts and an animation inside the script and a remote event inside of it:
Script:
local Tool = script.Parent
local Animation = script:FindFirstChild("Animation")
local player = script:FindFirstAncestorWhichIsA("Player") or game.Players:GetPlayerFromCharacter(script.Parent.Parent)
local character = player.Character or player.CharacterAdded:Wait()
local AnimationTrack = character:WaitForChild("Humanoid"):FindFirstChildOfClass("Animator"):LoadAnimation(Animation)
AnimationTrack.Priority = Enum.AnimationPriority.Action
script.Parent.Applying.OnServerEvent:Connect(function(mouseHit)
AnimationTrack:Play()
end)
LocalScript:
local tool = script.Parent
local re = tool:WaitForChild("Applying")
local mouse = game.Players.LocalPlayer:GetMouse()
tool.Activated:Connect(function()
re:FireServer(mouse.Hit)
end)
Why are you playing the animation on the server? you can just play the animation in the local script itself,
animations replicate.
local player = game.Players.LocalPlayer
repeat wait() until player.Character
local character = player.Character
local humanoid = character:WaitForChild("Humanoid")
local tool = script.Parent
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://id here"
local loaded = humanoid:LoadAnimation(animation)
tool.Equipped:Connect(function(mouse)
mouse.Button1Down:Connect(function()
loaded:Play()
end)
end)
I personally never use that property so I didnt know it returned an error just remove that line and everything should be fine. If you want the animation to be ontop of everything just change it from the animation editor itself.