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

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

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

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.

2 comments

0

Learned something new, I assumed the CharacterAdded() function only ran when a character first joined the game lmao

0

Perfect, thanks for the help!

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