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

i want only certain ppl t have the sword?

Asked by 9 years ago
local Players = { --List of players who get the sword
['Player1'] = true,
['Player2' = true, 
['Player3'] = true
}

Game.Players.PlayerAdded:connect(function(Player)
if Players[Player.Name] then
Game.ReplicatedStorage.Sword:Clone().Parent = Player:WaitForChild('Backpack')
--Make sure the sword name is "Sword" inside of ReplicatedStorage
end
end)


idk why it wont work

0
Is there a sword in replicatedstorage? HungryJaffer 1246 — 9y
0
yes ags5321 0 — 9y
0
is it named "Sword" HungryJaffer 1246 — 9y
0
Yes ags5321 0 — 9y
0
Yes ags5321 0 — 9y

1 answer

Log in to vote
1
Answered by 9 years ago

The script works fine, but you're missing a closing ] on line 3 after 'Player2'. The complete script is here:

local Players = { --List of players who get the sword
['Player1'] = true,
['Player2'] = true, 
['Player3'] = true
}

Game.Players.PlayerAdded:connect(function(Player)
if Players[Player.Name] then
Game.ReplicatedStorage.Sword:Clone().Parent = Player:WaitForChild('Backpack')
--Make sure the sword name is "Sword" inside of ReplicatedStorage
end
end)

If you check the output in Studio, you can catch such errors along with a line number and (brief) description of what's wrong. That will help you in your debugging efforts.

0
still doesnt work ags5321 0 — 9y
Ad

Answer this question