I want to make it so when a Player joins, it inserts a NumberValue in their head, because I am making a client sided game, but this Script won't work:
V = Instance.new("NumberValue") Workspace.ChildAdded:connect(function(child) print(child.Name) wait() V.Parent = child.Head V.Name = "Tacos" end)
All it takes is these 5 simple lines of code :D
game.Players.PlayerAdded:connect(function(plr) print(plr.Name) local v = Instance.new("NumberValue",plr) v.Name = "Tacos" end)
It's best that you insert the number value inside the player. For example, if they die or reset, you won't lose that current value.
Here ill try to help out
Code:
game.Players.PlayerAdded:connect(function(Player) print(Player.Name .. " Has joined the game.") Player.CharacterAdded:connect(function(Character) local V = Instance.new("NumberValue", Character:WaitForChild("Head")) -- Instance.new(Class, Parent) V.Name = "Tacos" end) end)
Try this instead.
game.Players.PlayerAdded:connect(function(player)--The function is called when player joins print(player.Name)--Prints his/her name wait() local V = Instance.new("NumberValue", player.Character.Head)--Inserts into the head V.Name = "Tacos" end)