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

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

Asked by 7 years ago
Edited 7 years ago

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
0
Is anything appearing in the output? itsJooJoo 195 — 7y
0
@itsJooJoo Nope. Precisionly 103 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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)
Ad

Answer this question