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

Why won't the gamepass give the tool?

Asked by 10 years ago
01wait(2)
02 
03 
04 
05gpid = 233549351
06tools = {"The Beans"}
07 
08GPS = game:GetService("GamePassService")
09function respawned(char)
10local player = game.Players:FindFirstChild(char.Name)
11print("Respawned")
12if char:FindFirstChild("Head") ~= nil then
13print("It's a Player!")
14if GPS:PlayerHasPass(player, gpid) then
15print("Has GPID")
View all 24 lines...

Thanks!

0
If there is an output, please post it. Grenaderade 525 — 10y

2 answers

Log in to vote
0
Answered by 10 years ago

There were three things that were potentially wrong here. 1: The name of the tool has a space 2: The connected function passes no arguments 3: (Not a real problem) Your code is not indented and it bothers me

Here is your code rewritten to address the second problem. I would strongly recommend that you use the ServerStorage service instead of Lighting.

01wait(2)
02 
03local gamePassID = 233549351
04local PassService = game:GetService("GamePassService")
05local tools = {"The Beans"}
06 
07function respawned(char)
08    local player = game.Players:FindFirstChild(char.Name)
09    print("Respawned")
10    if char:FindFirstChild("Head") then
11        print("It's a Player!")
12        if PassService:PlayerHasPass(player, gamePassID) then
13             print("Has GPID")
14                for i = 1, #tools do
15                    local tool = game.ServerStorage:FindFirstChild(tools[i]):Clone()
View all 24 lines...

Or, if you wanted to, you could put all the tools in a folder (Model) inside the ServerStorage. This address both the first and second problem

01wait(2)
02 
03local gamePassID = 233549351
04local PassService = game:GetService("GamePassService")
05local tools = game.ServerStorage.Tools:GetChildren()
06 
07game.Players.PlayerAdded:connect(function(char)
08    local player = game.Players:FindFirstChild(char.Name)
09    print("Respawned")
10    if char:FindFirstChild("Head") then
11        print("It's a Player!")
12        if PassService:PlayerHasPass(player, gamePassID) then
13            print("Has GPID")
14            for i, v in pairs(tools) do
15                local tool = v:Clone()
View all 22 lines...
0
game.Workspace.ChildAdded:connect(respawned(char)) W001: Unknown global 'char' iiCasual 20 — 10y
0
I just changed it DewnOracle 115 — 10y
Ad
Log in to vote
0
Answered by 10 years ago

There is nothing wrong I suggest that you name the tool "TheBeans" together like that and change the script where it says tools too = {"TheBeans"} then put the tool in Lightning must not be a model.

Answer this question