Hello! Im trying to reserve a item only for game devs, the script doesn’t work at all, and nothing came up in the output as an error nor warning sooooo…
Heres the scripts itself
local players = {"CarlosGamer81239, NubblyFry"}
local tool = game.ServerStorage.DEV_FuseNuke
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(chr)
for i = 1, #players do
if players[i] == plr.Name then
tool:Clone().Parent = plr:WaitForChild("Backpack")
end
end
end)
end)
**
Also, you don’t need to check for CharacterAdded, instead you can do this:
game.Players.PlayerAdded:Connect(function(plr
local char = plr.CharacterAdded:wait()
local backpack = plr:WaitForChild("Backpack")
for _,v in pairs(players) do
if plr.Name == v then
local newTool = tool:Clone()
newTool.Parent = backpack
newTool.Name = "Enter Name"
end
end
end)
It’s not the issue but using WaitForChild is good practice as sometimes the script loads before the item, and FindFirstChild will just return nil if it does, whereas WaitForChild will wait until it’s loaded.
local players = {"CarlosGamer81239, NubblyFry"}
local tool = game.ServerStorage:FindFirstChild("DEV_SwordyMesh")
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.CharacterAdded:wait()
local backpack = plr:WaitForChild("Backpack")
for _,v in pairs(players) do
if plr.Name == v then
local newTool = tool:Clone()
newTool.Parent = backpack
newTool.Name = "DEV_SwordyMesh"
end
end
end)
local players = {"CarlosGamer81239, NubblyFry"}
local tool = game.ServerStorage:FindFirstChild("DEV_FuseNuke")
game.Players.PlayerAdded:Connect(function(plr)
local char = plr.CharacterAdded:wait()
local backpack = plr:WaitForChild("Backpack")
for _,v in pairs(players) do
if plr.Name == v then
local newTool = tool:Clone()
newTool.Parent = backpack
newTool.Name = "DEV_FuseNuke"
end
end
end)
Your table isn’t separated properly. You need speech marks for each argument, and separate these arguments with a comma. Change your players table to this: