|
| 20 Feb 2016 03:36 AM |
while true do if game.Players.LocalPlayer.Character.Health == 0 then print(tostring(game.Players.LocalPlayer .. " has died")) game.Players.LocalPlayer.TeamColor = "Really black" end wait(0.2) end
This script changes your team if you die. Problem is, nothing happens whatsoever. What's wrong with this script?
It is a LocalScript in ReplicatedStorage. |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2016 03:43 AM |
| try putting it in starter gui |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2016 03:47 AM |
Character by itself doesn't have a health value, a child of it does, Humanoid.
To prevent errors in the future, use this:
local LocalPlayer = game.Players.LocalPlayer; local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:wait(); local Humanoid = Character:WaitForChild("Humanoid");
Humanoid.Died:connect(function() print(LocalPlayer.Name.. " has died."); LocalPlayer.TeamColor = "Really black"; end)
I've got rid of your while loop as it unnecessarily uses up lots of resources. I've made it print out the LocalPlayer's name, rather than the instance itself. I've used the 'or' statement to wait for the LocalPlayer's character to be added, sometimes the character isn't there! Also, I waited for the Humanoid from the character. Lasty, I used the .Died event in the Humanoid to get rid of the while loop.
Enjoying your stay at the Scripters Forum? Join this! http://www.roblox.com/My/Groups.aspx?gid=2582784 |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2016 03:53 AM |
^ Thanks! However, your script still does nothing. I also tried making it part of StarterGui, but still never worked. |
|
|
| Report Abuse |
|
|
|
| 20 Feb 2016 04:06 AM |
On this line : LocalPlayer.TeamColor = "Really black";
Change it to : LocalPlayer.TeamColor = BrickColor.new("Really black")
|
|
|
| Report Abuse |
|
|
| |
|
|
| 21 Feb 2016 07:11 PM |
OK, nevermind, just had to move it to, you guessed it, StarterGui!
Thanks everyone! |
|
|
| Report Abuse |
|
|
|
| 23 Feb 2016 07:41 PM |
| I need help making the spawn where to theres only 4 pleyers per team, theres 4 teams. |
|
|
| Report Abuse |
|
|