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

How could i save tools awarded with gamepasses after death?[UPDATED]

I'm awarding items from gamepasses and everything works except i can't seem to save them after death and rejoining the game.I've tried many different alternatives but to no avial.This script here is my latest attempt to make it work.

Thanks for your time.

local GC = player.Backpack:WaitForChild("GravityCoil",2)

game.Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(character)
        if marketplaceService:PlayerOwnsAsset(player, gamePassId) then
			if GC == nil then
            GravityCoil:Clone().Parent = player.Backpack
			        end
			end
    end)
end)

1 answer

Well if the players had to buy a gamepass, you don't need to save them or anything, just check if they own the gamepass. We're going to use the PlayerAdded event for this one.

local GAMEPASS_ID = 123
local marketplaceService = game:GetService("MarketplaceService")
local gravityCoil = game.ServerStorage.Tools.GravityCoil

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		if marketplaceService:PlayerOwnsAsset(player, GAMEPASS_ID) then
			gravityCoil:Clone().Parent = player.Backpack
		end
	end)
end)

We don't need to save the GravityCoil inside the player, we can just put it inside of ServerStorage. You can also clone to StarterGear if you'd like. I just chose this way as an easy method of allowing the player to buy the gamepass when they're in-game and still get the coil when they respawn, but there are other ways to do that.

3 comments

0

Unfortunately it doesn't work and i have no idea why

0

I've tried your way and when it didn't work i tried the script above and still no luck

0

What is wrong? Have you tried using print() statements, breakpoints, or checked the output?

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