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

Removing a tool from a players backpack if they don't have a gamepass?

So basically I want to remove a tool from a players backpack if they don't have the gamepass. I tested this out since I don't have the pass. It doesn't remove the FAL when it's in my backpack. It's a localscript in starterpack.

local player = game.Players.LocalPlayer

if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 415462481) then
		print ("FAL pass owned")
else
	while true do
		player.Backpack.FAL:Destroy()
	end
	end

2 comments

0

Is anything appearing in the output?

0

@itsJooJoo Nope.

1 answer

✓ Accepted answer

I personally think it would be a better idea to store the tool in ReplicatedStorage (or ServerStorage) and clone the tool to the player's backpack when they spawn if they own the gamepass. An exploiter could potentially disable this script.

local tool = game.ReplicatedStorage.FAL -- Change to wherever you store the tool
local gamepass = 415462481

game.Players.PlayerAdded:connect(function(player)
	player.CharacterAdded:connect(function()
		if game:GetService("MarketplaceService"):PlayerOwnsAsset(player, 415462481) then -- Check if the own the tool
			tool:Clone().Parent = player.Backpack -- Clone it to their backpack
		end
	end)
end)

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