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

Instant Respawn Gamepass Script?

So I made a question earlier about this but I think I might have found an issue with it but I deleted the old form so here's a new one.

So I am trying to make an instant respawn gamepass script where if a user owns a gamepass, they will instantly respawn instead of having to wait for my 7-second death scene.

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamepassId = 8139794 -- My gamepass ID
 
game.Players.PlayerAdded:connect(function(plr)
	plr.CharacterAdded:connect(function(char)
    repeat wait() until char.Humanoid
    char.Humanoid.Died:connect(function()
    if MarketplaceService:UserOwnsGamePassAsync(char.UserId, gamepassId) then
    plr:LoadCharacter()
end
end)
end)
end)

I do not know why it doesn't work, there is nothing in the logs from that script.

1 answer

✓ Accepted answer

The issue with your script is you're looking up the ID from the Character, not the Player object. Since char.UserId doesn't exist, the check always fails, and nothing happens.

Try using the following code instead:

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
local gamepassId = 8139794 -- My gamepass ID

game.Players.PlayerAdded:connect(function(plr)
    plr.CharacterAdded:connect(function(char)
    repeat wait() until char.Humanoid
    char.Humanoid.Died:connect(function()
        if MarketplaceService:UserOwnsGamePassAsync(plr.UserId, gamepassId) then
            plr:LoadCharacter()
        end
    end)
    end)
end)

Hope I helped!

1 comment

0

Ah, I noticed this just now before looking at this, I removed the local Players part to but as you added it I will too. Thanks!

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