I made a script that changes a random player's Character name but I'm getting an error when it gets to the name change part of my code.
The script
local players = game.Players:GetChildren() local hunter = players[math.random(1)] hunter.Character.Name = "The Hunter - Watch out!"
Modifying a player's character name will result in an error. If you want to display text above someone's head, you can use BillboardGuis instead.
Also, right now it'll always pick the first player that joined the game instead of a random one, so instead of doing math.random(1)
, you can do math.random(1, #players)
.
Hope this helped
Edit: The Humanoid object has a DisplayName property, so if you're lazy and can't be bothered to make a BillboardGui you can just use that.
local players = game.Players:GetChildren() local hunter = players[math.random(1,1)] -- the ending number hunter.Character.Name = "The Hunter - Watch out!"
Oh right you are getting an error because you have not included a second value in math.random. Let me fix this script for you:
local players = game.Players:GetChildren() local hunter = players[math.random(1, #players)] hunter.Character.Humanoid.Name = "The Hunter - Watch out!" -- The humanoid actually stores the name of the character silly mistake.
I don't know if this script will work, but try it out.