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

[UNANSWERED] Not sure what's wrong?

Asked by 9 years ago

Trying to give tools to certain players. Script is in Workspace, tools are in Server Storage. No errors appear or anything, not sure what's wrong.

01Allowed = {"Player"}
02 
03local MK48 = game.ServerStorage["Mk-48"]
04local MK17 = game.ServerStorage["Mk-17"]
05local EV = game.ServerStorage["Explosive vest"]
06 
07function onPlayerSpawned(p)
08for _,v in pairs(Allowed) do
09if p.Name:lower() == v:lower() then
10MK48:clone().Parent = p.Backpack
11MK17:clone().Parent = p.Backpack
12EV:clone().Parent = p.Backpack
13end
14end
15end
View all 21 lines...
0
Perhaps use WaitForChild. game.ServerStorage:WaitForChild("Mk-48") funyun 958 — 9y
0
Allowed = {"Player", "Player1"} XToonLinkX123 580 — 9y

1 answer

Log in to vote
0
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

Are you sure the Player being spawned is named "Player"?

Additionally, you can make this more efficient by using a Dictionary:

01Allowed = {Player = true}
02 
03local MK48 = game.ServerStorage["Mk-48"]
04local MK17 = game.ServerStorage["Mk-17"]
05local EV = game.ServerStorage["Explosive vest"]
06 
07function onPlayerSpawned(p)
08    if Allowed[p.Name] then
09        MK48:Clone().Parent = p.Backpack
10        MK17:Clone().Parent = p.Backpack
11        EV:Clone().Parent = p.Backpack
12    end
13end
14 
15game.Players.PlayerAdded:connect(function(p)
16    p.CharacterAdded:connect(function()
17        onPlayerSpawned(p)
18    end)
19end)
0
It doesn't work, I'm really clueless at this point. Arceus3317 10 — 9y
0
Must be something wrong on your end then. unmiss 337 — 9y
Ad

Answer this question