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

How to give a tool with the new gamepass system?

I tried this:

-- In workspace normalscript
local MpS = game:GetService"MarketplaceService"
local gamepass = 4775497
local tool = {"Glock 18"}

workspace.ChildAdded:connect(function(plr)
	local player = game.Players:FindFirstChild(plr.Name)
	local backpack = player:WaitForChild("Backpack")
	if MpS:UserOwnsGamePassAsync(player.UserId, gamepass) then
		game.ServerStorage:FindFirstChild(tool):Clone().Parent = backpack
	end
end)

i know this is a bad way but i tried something...

2 comments

0

Why are you using Lighting as storage?

0

I am using ServerStorage but that was for something else a test

1 answer

✓ Accepted answer

###You shouldn’t be using Lighting as storage, as this is deprecated and not supported by ROBLOX. Move the tool to ReplicatedStorage for client and server access. Move to ServerStorage for server only access. Your problem is on lines 4 and lines 10, you’re trying to find a table in Lighting. Index the item in the table.

local MpS = game:GetService"MarketplaceService
local gamepass = 4775497
local tool = {"Glock 18"}

game:GetService("Players").PlayerAdded:Connect(function(plr)
    if Mps:UserOwnsGamePassAsync(plr.UserId, gamepass) then
        if game:GetService("ServerStorage"):FindFirstChild(tool[1]) then
            local clone = game:GetService("ServerStorage")[tool[1]]:Clone()
            clone.Parent = player.StarterGear
            clone:Clone().Parent = player.Backpack
        end
    end
end)

###On a side note, switch to Connect, as ROBLOX may remove connect in the future.

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