local gamepass = script:WaitForChild("GamePassId") local service = game:GetService("GamePassService") game.Players.PlayerAdded:connect(function(player) if service:PlayerHasPass(player,gamepass.Value)then local tools = game.ReplicatedStorage:WaitForChild("Tools") for i,v in pairs(tools:getChildren())do if v:isA("Tool")then v:Clone().Parent = player:WaitForChild("Backpack") v:Clone().Parent = player:WaitForChild("StarterGear") end end end end)
OK, so something weird happened, when I exited studio then came back to this, the unknown global error was gone. But when I test it out, I don't get what I should for the gamepass. So far it's been a big trial and error for me lol. And the whole script is just named Script, has an IntValue attached to it. Yeah, I'm a newbie at scripting sorry.
PlayerHasPass
method was broken in the April game pass update, where game passes were no longer asset IDs. You'll need to use Marketplace:UserOwnsGamePassAsync()
.local gamepass = script:WaitForChild("GamePassId") local service = game:GetService("GamePassService") local gamepass = script:WaitForChild("GamePassId") local service = game:GetService("MarketplaceService") game:GetService("Players").PlayerAdded:Connect(function(player) -- uppercase C if service:UserOwnsGamePassAsync(player.UserId,gamepass.Value) then local tools = game:GetService:WaitForChild("Tools") for i,v in pairs(tools:GetChildren()) do -- uppercase G if v:IsA("BackpackItem") then -- IsA not isA v:Clone().Parent = player:WaitForChild("Backpack") v:Clone().Parent = player:WaitForChild("StarterGear") end end end end)
:connect()
, :getChildren()
, :isA()
are deprecated, make the first letter of each word an uppercase instead.