I made an animation and and inserting this local script under it in the workspace, and am wondering how to make this trigger whenever I respawn/join the game.
local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=2120495452" local animTrack = Humanoid:LoadAnimation(animation) animTrack:Play()
I have been stuck for a while trying to fix this please help :)
This is an easy fix. First, you'll want to use an event for whenever something is added to the workspace. In this case it'll be your player. This could be any object though, so we'll need to confirm that this is in fact a player. We'll want to check if it has a humanoid inside of it. Here is it with your script inside of the event.
game.Workspace.ChildAdded.connect(function(child) if child:FindFirstChild('Humanoid') then local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=2120495452" local animTrack = Humanoid:LoadAnimation(animation) animTrack:Play() end end)
If you wanted it for just YOU specificaly, just do a simple check of the player's nbame. Like this:
game.Workspace.ChildAdded.connect(function(child) if child:FindFirstChild('Humanoid') then if child.Name == "NoahJordan21" then local animation = Instance.new("Animation") animation.AnimationId = "http://www.roblox.com/Asset?ID=2120495452" local animTrack = Humanoid:LoadAnimation(animation) animTrack:Play() end end end)
i just want to add, you haven't identified what Humanoid is in local aimtrack. If you haven't done that elsewhere in the script, you could just do:
local Humanoid = child.Humanoid
Just make sure you put that in the event.