How to play animation when player joins?

Hi there guys, so I was recently trying to make it so that a first-person animation plays when you join the game, and then you would continue on with the game. It’s kind of like that one cutscene from the horror game “Granny” when you first wake up from the bed and then continue on to do other things. I’ve already created the animation, exported it, but do not know how to actually implement it into my game.

1 Like

You should be able to use game.Players.PlayerAdded to get when a new player joins the game. After this, load the animation and play it. Here is a page that should help with playing animations: Using Animations | Roblox Creator Documentation

1 Like

I’ve tried but it still doesn’t work. Should I re-create the animation using the character inserter plugin the moon animator provides or just the regular studio one?

Which part doesn’t work? Can you send a picture of your code?

1 Like

The simplest way that I utilise for this is making a LocalScript in StarterPlayerScripts where the script is short and will only run once on join:

local plr = game.Players.LocalPlayer
local plrChar = plr.Character or plr.CharacterAdded:Wait()
local hum = plrChar:WaitForChild("Humanoid")

local anim = Instance.new("Animation")
anim.AnimationId = "rbxassetid://9083439339"

local loadAnim = hum:LoadAnimation(anim)
loadAnim:Play()

If the animation plays too fast, you can always add task.wait() as this will execute the second the player’s character loads.

3 Likes

I originally used this


local player = Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
	character = player.CharacterAdded:Wait()
end
local humanoid = character:WaitForChild("Humanoid")
local animator = humanoid:WaitForChild("Animator")

-- Create new "Animation" instance
local kickAnimation = Instance.new("Animation")
-- Set its "AnimationId" to the corresponding animation asset ID
kickAnimation.AnimationId = "rbxassetid://9083439339"

-- Load animation onto the animator
local kickAnimationTrack = animator:LoadAnimation(kickAnimation)

-- Play animation track
kickAnimationTrack:Play()

-- If a named event was defined for the animation, connect it to "GetMarkerReachedSignal()"
kickAnimationTrack:GetMarkerReachedSignal("KickEnd"):Connect(function(paramString)
	print(paramString)
end)

But I think it might have something to do with the actual animation itself…

I’ve tried, but the script seems to not work. There were no errors in the actual script itself, but I believe there is an issue with the animation. Since the animation requires manipulation of the camera, it might be different for studio to process it… or maybe that is a myth? I’ve never really done player rig camera manipulations/animations before.

2 Likes