generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Problem with script that changes teams

Previous Thread :: Next Thread 
imaginaryUberlyuber is not online. imaginaryUberlyuber
Joined: 15 Jul 2012
Total Posts: 208
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
myactivetestplace is not online. myactivetestplace
Joined: 11 Jul 2015
Total Posts: 3733
20 Feb 2016 03:43 AM
try putting it in starter gui
Report Abuse
powerhotmail123 is not online. powerhotmail123
Joined: 11 Apr 2011
Total Posts: 5041
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
imaginaryUberlyuber is not online. imaginaryUberlyuber
Joined: 15 Jul 2012
Total Posts: 208
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
SimpIyBananas is not online. SimpIyBananas
Joined: 01 Nov 2015
Total Posts: 134
20 Feb 2016 04:06 AM
On this line : LocalPlayer.TeamColor = "Really black";

Change it to : LocalPlayer.TeamColor = BrickColor.new("Really black")


Report Abuse
imaginaryUberlyuber is not online. imaginaryUberlyuber
Joined: 15 Jul 2012
Total Posts: 208
21 Feb 2016 07:10 PM
Still does nothing.
Report Abuse
imaginaryUberlyuber is not online. imaginaryUberlyuber
Joined: 15 Jul 2012
Total Posts: 208
21 Feb 2016 07:11 PM
OK, nevermind, just had to move it to, you guessed it, StarterGui!

Thanks everyone!
Report Abuse
Argento1012 is not online. Argento1012
Joined: 19 Apr 2013
Total Posts: 4
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image