--My code is:
local id = 6485848 local barret = game.ServerStorage:FindFirstChildOfClass("Tool")
game.Players.PlayerAdded:Connect(function(player) if game:GetService("MarketplaceService"):UserOwnsGamePassAsync(player.userId,id) then local barretClone = barret:Clone() barretClone.Parent = player:WaitForChild("Backpack") end end)
--This script only adds the tool only when the player enters the game, not when they spawn. I tried using CharacterAdded but that is not a child of players, any suggestions?
try this script, place it in the ServerScriptStorage
01 | local gpid = 6331302 -- Gamepass ID |
02 | tools = { "HasSpeedPassBool" } --Tool Name, place the item in a tool in the ServerStorage |
03 |
04 | GPS = game:GetService( "GamePassService" ) |
05 | GPS 2 = game:GetService( "MarketplaceService" ) |
06 | game:GetService( "Players" ).PlayerAdded:connect( function (player) |
07 | player.CharacterAdded:connect( function (char) |
08 | if char:FindFirstChild( "Humanoid" ) ~ = nil then |
09 | print ( "Has humanoid" ) |
10 | if GPS 2 :UserOwnsGamePassAsync(player.UserId,gpid) then -- this is for the new gamepass gpid, not the old assetid |
11 | for _,v in pairs (tools) do |
12 | if game:GetService( "ServerStorage" ):FindFirstChild(v) then |
13 | game:GetService( "ServerStorage" ):FindFirstChild(v):clone().Parent = player.Backpack |
14 | end |
15 | end |