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

Instant Respawn Gamepass Script?

Asked by 4 years ago
Edited 4 years ago

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

Log in to vote
1
Answered by 4 years ago

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!

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! DiamondRules01 56 — 4y
Ad

Answer this question