|
| 20 Feb 2013 05:52 AM |
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function() plr.Character.Humanoid.MaxHealth = 101 if plr.Character.Humanoid.Health <= 1 then plr.Character:MoveTo(Vector3.new(1, 1, 1)) end end) end)
There's a few problems here. It (almost) does what it should, but with a few errors and one thing that needs changing.
I need it to give the person the maxhealth always, even after they die. This does not reset the player's maxhealth after they die to 101, instead 100.
The MoveTo(Vector3.new(1,1,1)) doesn't work either. |
|
|
| Report Abuse |
|
|
digpoe
|
  |
| Joined: 02 Nov 2008 |
| Total Posts: 9092 |
|
|
| 20 Feb 2013 05:56 AM |
The MoveTo(Vector3.new(1,1,1)) needs to be changed to the place where you want the character to be moved to; it'll just be moved to the point 1, 1, 1
The MaxHealth is always given - I'll psudeocode it to show you what it does:
player joined - index this as plr plr's character spawns set plr's charater's humanoid's MaxHealth to 101 IF the Health property of plr's character's Humanoid is less than or equal to 1, run: move the Character to the position 1, 1, 1 end end end |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2013 06:19 AM |
| I know all that, but it's not working! It doesn't even move the character to 1,1,1! |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2013 06:19 AM |
| And after re-spawn, the player's health is equal to 100. |
|
|
| Report Abuse |
|
|
| |
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 20 Feb 2013 07:07 AM |
Try adding a wait for humanoid
while (not plr.Character:FindFirstChild("Humanoid")) do wait(0.1) end
Obviously doesn't have to be 0.1, but when I'm doing checks like that, I always use 0.1 |
|
|
| Report Abuse |
|
|
cart6157
|
  |
| Joined: 28 Feb 2009 |
| Total Posts: 2194 |
|
|
| 20 Feb 2013 07:18 AM |
| Your script triggers when a player dies, and obviously a player that just spawned has 100 health. |
|
|
| Report Abuse |
|
|
cart6157
|
  |
| Joined: 28 Feb 2009 |
| Total Posts: 2194 |
|
|
| 20 Feb 2013 07:21 AM |
Try welding this into your script:
plr.Character.Humanoid.Died:connect(function() wait(5) -- How long it takes for a player to spawn plr.Torso.CFrame = CFrame.new(1,1,1) end
This script automatically teleports a player when he spawns to position 1,1,1. |
|
|
| Report Abuse |
|
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 20 Feb 2013 07:24 AM |
@Cart He used CharacterAdded under the PlayerAdded, so that means whenever the character gets added (including when the player respawns) it will run.
There should be nothing wrong with the event he's using. And your way might work but it doesn't seem the best of methods, because if it takes slightly longer than 5 seconds or less then either the character could be actually moving a little bit then get moved, or the script could error because the torso isn't there yet.
Also, you used plr.Torso when plr is equal to the actual player, you forgot to add plr.Character |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2013 09:06 AM |
| Everything now works fine, EXCEPT the MoveTo(1,1,1) line. It doesn't do anything. |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2013 09:08 AM |
Oh, the MoveTo was formatted incorrectly! xD didnt see that.
Workspace.Player1:MoveTo(Vector3.new(1,1,1)) |
|
|
| Report Abuse |
|
|
| |
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 20 Feb 2013 09:11 AM |
Oh, I thought you just shortened it.
Yes, you need to convert it to Vector3. |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2013 09:19 AM |
Oh! Damnit, again, it's broken.
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function() while (not plr.Character:FindFirstChild("Humanoid")) do wait(0.1) end plr.Character.Humanoid.MaxHealth = 1000 plr.Character.Humanoid.Health = 1000
if plr.Character.Humanoid.Health <= 900 then -- THIS BIT plr.Character:MoveTo(Vector3.new(1,1,1)) -- UND THIS end
end) end)
|
|
|
| Report Abuse |
|
|
200AB
|
  |
| Joined: 24 Aug 2010 |
| Total Posts: 1604 |
|
|
| 20 Feb 2013 09:22 AM |
What.... I really have no idea, I don't see a thing wrong with it.
Sorry, maybe someone else will spot it. |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2013 09:53 AM |
| Someone, try it for yourself! |
|
|
| Report Abuse |
|
|
awas3
|
  |
| Joined: 24 Oct 2010 |
| Total Posts: 2854 |
|
|
| 20 Feb 2013 09:58 AM |
Try this:
game.Players.PlayerAdded:connect(function(plr) plr.CharacterAdded:connect(function() while (not plr.Character:FindFirstChild("Humanoid")) do wait(0.1) end plr.Character.Humanoid.MaxHealth = 1000 plr.Character.Humanoid.Health = 1000
if plr.Character.Humanoid.Health <= 900 then plr.Character.Torso.CFrame = CFrame.new(1,1,1) end
end) end)
l=~/A3\~=l |
|
|
| Report Abuse |
|
|