Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How do I check for a game pass after the player respawns?

Asked by 5 years ago

When the player first spawns and has a gamepass, they have the ability to run faster, but when the player dies and respawns it sets the walk speed back to the default value. How could i check for a gamepass when the player respawns?

1 answer

Log in to vote
2
Answered by
yHasteeD 1819 Moderation Voter
5 years ago
Edited 5 years ago

You can use player.CharacterAdded for give speed again

here is a example:

game.Players.PlayerAdded:Connect(function(player)
    print("Player added, player name is: " .. player.Name)
    player.CharacterAdded:Connect(function(char)
        print("Char of player " .. player.Name .. " added!")
    end)
end)

here is the script:


local gamepass_id = 0 -- Your gamepass id local run_speed = 32 -- speed if player have gamepass game.Players.PlayerAdded:Connect(function(player) player.CharacterAdded:Connect(function(char) if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.UserId,gamepass_id) then -- detect if player have gamepass. char:WaitForChild("Humanoid").WalkSpeed = run_speed -- change the speed end end) end)

Wiki pages:

MarketplaceService

UserOwnsGamePassAsync

PlayerAdded

CharacterAdded


Hope it helped :)

Errors? tell-me on comments.

0
Learned something new, I assumed the CharacterAdded() function only ran when a character first joined the game lmao cmgtotalyawesome 1418 — 5y
0
Perfect, thanks for the help! reki1199 0 — 5y
Ad

Answer this question