Hey guys, I'm making a game which requires a punching tool to be in the starterpack and players may be punching eachother inside the lobby. Ideally, I'd be wanting to give them the tool once they've teleported into the battlefield and remove it once they die, but i'm not sure how to do this. So, i've come up with a workaround. As I said before, players may be hurting eachother during the lobby phase, and when they've teleported to the battlefield their health may already be low. I want to heal all the players when they've teleported so that nobody has an unfair advantage.
I've tried this so far, but I haven't had any luck.
local plrs = game.Players:GetChildren() for i = 1,#plrs do -- Teleport the players randomly local num = math.random(1,8) plrs[i].Character.Head.CFrame = CFrame.new(workspace.Teleports["Part"..num].Position) plrs[i].Character.Parent = workspace.Ingame -- From Here plrs.Health = ("Humanoid").MaxHealth -- To here does not work.
Any help is appreciated!
character.Humanoid
has a Health property, which can be changed with a script.
In your script it's not working because ("Humanoid") is just.. Not the way to do that.
Edit your line 8 to this:
plrs[i].Character.Humanoid.Health = plrs[i].Character.Humanoid.MaxHealth
You also forget putting the [i], which (in this script) is the index number of an element (the currently looping element) in the table.
Try this script, which waits for the humanoid too:
local plrs = game.Players:GetChildren() for i = 1,#plrs do -- Teleport the players randomly local num = math.random(1,8) plrs[i].Character.Head.CFrame = CFrame.new(workspace.Teleports["Part"..num].Position) plrs[i].Character.Parent = workspace.Ingame -- From Here plrs[i].Character.Humanoid.Health = plrs[i].Character.Humanoid.MaxHealth -- To here does not work. end