I want the player to start an animation I have made when they click a brick. I have filtering enabled turned on. Here is the LocalScript for them to send the event to start the event/animation
script.Parent.tool.detector.ClickDetector.MouseClick:Connect(function() print("local script") script.Parent.animate:FireServer(2435453180) print("local script") end)
This is the script that receives the event
script.Parent.animate.OnServerEvent:Connect(function(player,animationID) local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID local loadedAnimation = game.Workspace[player.Name].Humanoid:LoadAnimation(animation) loadedAnimation:Play() print("Server script") end)
When I hit play and click the button it does nothing, and the output says nothing.
Playing animations on a player should be done on a local script. If you want to play an animation on NPC (Non-player controlled) then play the animation using a server script.
See more of that here. Look at the bit on "Should I load on Server or Client"
You have the right idea just don't use a server script at all.
In Local Script:
local player = game.Players.LocalPlayer local character = player.Character or player.CharacterAdded:Wait() local humanoid = character:WaitForChild("Humanoid") local animationID = 2435453180 local animation = Instance.new("Animation") animation.Parent = humanoid animation.AnimationId = "http://www.roblox.com/Asset?ID="..animationID local part = workspace:WaitForChild("Part") local clickDetector = part:WaitForChild("ClickDetector") clickDetector.MouseClick:Connect(function() --I believe you can load the animation outside of this function too local animTrack = humanoid:LoadAnimation(animation) animTrack:Play() end)
Let me know if you need an explanation for this. It really just is not having to use a server script or RemoteEvents when you don't need to.
edit; property fix & format