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.
01 | Allowed = { "Player" } |
02 |
03 | local MK 48 = game.ServerStorage [ "Mk-48" ] |
04 | local MK 17 = game.ServerStorage [ "Mk-17" ] |
05 | local EV = game.ServerStorage [ "Explosive vest" ] |
06 |
07 | function onPlayerSpawned(p) |
08 | for _,v in pairs (Allowed) do |
09 | if p.Name:lower() = = v:lower() then |
10 | MK 48 :clone().Parent = p.Backpack |
11 | MK 17 :clone().Parent = p.Backpack |
12 | EV:clone().Parent = p.Backpack |
13 | end |
14 | end |
15 | end |
Are you sure the Player being spawned is named "Player"?
Additionally, you can make this more efficient by using a Dictionary:
01 | Allowed = { Player = true } |
02 |
03 | local MK 48 = game.ServerStorage [ "Mk-48" ] |
04 | local MK 17 = game.ServerStorage [ "Mk-17" ] |
05 | local EV = game.ServerStorage [ "Explosive vest" ] |
06 |
07 | function onPlayerSpawned(p) |
08 | if Allowed [ p.Name ] then |
09 | MK 48 :Clone().Parent = p.Backpack |
10 | MK 17 :Clone().Parent = p.Backpack |
11 | EV:Clone().Parent = p.Backpack |
12 | end |
13 | end |
14 |
15 | game.Players.PlayerAdded:connect( function (p) |
16 | p.CharacterAdded:connect( function () |
17 | onPlayerSpawned(p) |
18 | end ) |
19 | end ) |