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

Why are these VIP items not saving after death?

So I have a few scripts that give certain items when you buy certain levels of VIP, and that has worked fine. What I just noticed today is that after I die, I don't keep any of the items, and they only stay in my inventory for the life I join the game in.

The tool is placed into Startergear, so I don't know the problem.

This is the script

local passId = 254941359

local potato = game.Lighting:WaitForChild("VIP")


function isAuthenticated(player) 
    return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId)
end

game.Players.PlayerAdded:connect(function(plr) -- player is already defined
    if isAuthenticated(plr) then
        print(plr.Name .. " has bought the game pass with id " .. passId)
        potato:Clone().Parent = plr.Backpack
        potato:Clone().Parent = plr.StarterGear
    end
end)

Please respond, this is kind of urgent.

1 answer

PlayerAdded is only fired when a player joins the server. Use character added instead so that everytime the player respawns their character is readded to the game and therefore this script will give them their gear back

local passId = 254941359

local potato = game.Lighting:WaitForChild("VIP")


function isAuthenticated(player) 
    return game:GetService("MarketplaceService"):PlayerOwnsAsset(player, passId)
end

game.Players.PlayerAdded:connect(function(plr) -- player is already defined
	plr.CharacterAdded:connect(function(Character) --will check when character is readded(cause of death usually) and readd those tools. You can now use Character to reference the character and plr to reference the player
    		if isAuthenticated(plr) then
       			print(plr.Name .. " has bought the game pass with id " .. passId)
        		potato:Clone().Parent = plr.Backpack
        		potato:Clone().Parent = plr.StarterGear
    	end
end)


2 comments

0

Thank you, I didn't know what existed. Your script didn't work at first, but it was only because of a missing 'end'

0

oh, rip :P, sorry bout that!

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