My goal: Give certain player Ids tools in the serverstorage and change their nametag colour to be yellow.
Issue:
This error passes:
And this is the code:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
if player.UserId == 116571791 then
game.ServerStorage.Tools:FindFirstChild('AA-12'):Clone().Parent = player.Backpack
player.Character.HumanoidRootPart:FindFirstChild('NameTag')
local tag = player.Character.HumanoidRootPart.NameTag
tag.PlayerName.TextColor3.Color3 = Color3:new(255, 247, 0)
end
if player.UserId == 556697206 then
game.ServerStorage.Tools:FindFirstChild('AA-12'):Clone().Parent = player.Backpack
player.Character.HumanoidRootPart:FindFirstChild('NameTag')
local tag = player.Character.HumanoidRootPart.NameTag
tag.PlayerName.TextColor3.Color3 = Color3:new(255, 247, 0)
end
if player.UserId == 53539000 then
game.ServerStorage.Tools:FindFirstChild('AA-12'):Clone().Parent = player.Backpack
player.Character.HumanoidRootPart:FindFirstChild('NameTag')
local tag = player.Character.HumanoidRootPart.NameTag
tag.PlayerName.TextColor3.Color3 = Color3:new(255, 247, 0)
end
I’ve redone this for you but please also look into the articles I provided to have an understanding on what’s going on.
Here:
local function provideGunToPlayer(player)
game.ServerStorage.Tools:FindFirstChild('AA-12'):Clone().Parent = player.Backpack
player.Character.HumanoidRootPart:FindFirstChild('NameTag')
local tag = player.Character.HumanoidRootPart.NameTag
tag.PlayerName.TextColor3.Color3 = Color3:new(255, 247, 0)
end
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function()
if player.UserId == 116571791 or player.UserId == 556697206 or player.UserId == 53539000 then
provideGunToPlayer(player)
end
end)
end)
(Let me know if this doesn’t work I don’t have a way to test it)