I've made a gamepass that is supposed to make it so that when it's purchased you will get a faster respawn time, when it comes to marketplace scripts I'm not very good at them so could someone help me?
01 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
02 | local player = game:GetService( "Players" ) |
03 | local id = 971827976 |
04 |
05 | game.Players.PlayerAdded:Connect( function (plr) |
06 | plr.CharacterAdded:Connect( function (chr) |
07 | if MarketplaceService:UserOwnsGamePassAsync(player.UserId, id) then |
08 | repeat wait() until chr.Humanoid |
09 | chr.Humanoid.Died:Connect( function () |
10 | wait(. 3 ) |
11 | plr:LoadCharacter() |
12 | end ) |
13 | end |
14 | end ) |
When using CharacterAdded event don't use the player variable.
01 | local MarketplaceService = game:GetService( "MarketplaceService" ) |
02 | local player = game:GetService( "Players" ) |
03 | local id = 971827976 |
04 |
05 | game.Players.PlayerAdded:Connect( function (plr) |
06 | plr.CharacterAdded:Connect( function (chr) |
07 | if MarketplaceService:UserOwnsGamePassAsync(game.Players:FindFirstChild(chr.Name).UserId, id) then |
08 | repeat wait() until chr.Humanoid |
09 | chr.Humanoid.Died:Connect( function () |
10 | wait(. 3 ) |
11 | plr:LoadCharacter() |
12 | end ) |
13 | end |
14 | end ) |
15 | end ) |