Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to give a certain player a animation?

Hello!

I would like to know how do I give a certain animation to a player who bought a gamepass? The ninja animation. I have the animation inside a localscript.

1 comment

0

Use CharacterAdded() and whenever their character loads delete the animate script and replace it with yours. (didn't test this it might just break it.)

1 answer

✓ Accepted answer

This is the way I do it. First of all, you need to find the player's character. Inside the character will be a script called 'Animate' and inside that script will be many StringValues AND inside those will be the Animations. To change say the walking animation, you would do this:

--Assuming you already have the Character
Character.Animate.walk.WalkAnim.AnimationId = "rbxassetid://180426354" -- Replace the numbers with the id of the animation you want to use.

There are other ways to do this but this way doesn't require you to delete the default animation script therefore you don't need to make your own.

Here's how it should look like in the end (server script):

local players = game:GetService("Players")
local GamePassId =  --Put the id of the gamepass here
local WalkAnimationId =  --Put the id of the animation here

players.PlayerAdded:Connect(function(player)
    if game:GetService("GamePassService"):PlayerHasPass(player, GamePassId) then 
        print(player.Name .. " has the game pass!")
	repeat wait() until player.Character
	player.Character.Animate.walk.WalkAnim.AnimationId = ("rbxassetid://"..WalkAnimationId)
    else
        print(player.Name .. " doesn't have the game pass...")
    end
end)

For more information: https://www.robloxdev.com/api-reference/function/GamePassService/PlayerHasPass

This discussion is preserved as it was. New answers, comments, and votes are closed.