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

Gamepass Gears disappear when I respawn?

Hi guys I'm working on an obby here

Problem: Whenever I test my obby, it gives me the gamepass gears like normal right? Well, when I tried died in my obby and I respawn, my gears just disappeared?!? Let me know if you have an answer!

Script:

local MarketplaceService = game:GetService("MarketplaceService")
local Players = game:GetService("Players")
 
local gamePassID = 0000000  -- Change this to your game pass ID
 
local function onPlayerAdded(player)
 
	local hasPass = false
 
	-- Check if the player already owns the game pass
	local success, message = pcall(function()
		hasPass = MarketplaceService:UserOwnsGamePassAsync(player.UserId, gamePassID)
	end)
 
	-- If there's an error, issue a warning and exit the function
	if not success then
		warn("Error while checking if player has pass: " .. tostring(message))
		return
	end
 
	if hasPass == true then
		game.ServerStorage.Name:Clone().Parent = player.Backpack
		-- Assign this player the ability or bonus related to the game pass
		--
	end
end
-- Connect "PlayerAdded" events to the "onPlayerAdded()" function
Players.PlayerAdded:Connect(onPlayerAdded)

1 answer

The Backpack is cleared upon the Player resetting. If you wish to have a persistent tool, store a duplicate asset into StarterPack to have it replicated upon respawn.

6 comments

0

You mean StarterPack?

0

Yes I think she means starter pack

0

@Feahren Ok so I tried doing yours by placing my assets in ServerStorage and create a duplicate to be put in StarterPack but the result was basically two sets of the same gears and when I die it onlys leaves me to have to the StarterPack set of the gears?!?

0

Apologies, I wrote this very late at night. Essentially, you are to Clone a copy into StarterPack when moving the Gamepass Tool into the Backpack.

0

So you are saying that I should change the Backpack to StarterPack in the script but move the tool to where? I'm sorry I can't find what you mean by "Backpack" in Explorer

0

And also if you have time can you write a new script sample in your answer please! Thank you for your help!

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