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: healthchanged not firing

Previous Thread :: Next Thread 
unwarranted is not online. unwarranted
Joined: 05 Jun 2009
Total Posts: 1087
05 Jun 2016 08:54 PM
so in a localscript in starterplayerscripts i have this healthchanged event that works, but once you reset, it stops working.

local Player = game.Players.LocalPlayer

Player.Character.Humanoid.HealthChanged:connect(function()
print('test')
end)



mom wheres the spaghetti
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
05 Jun 2016 08:56 PM
Because it's in StarterPlayerScripts it doesn't persist, like we talked about yesterday :)
This is another great opportunity to use this the StarterGui with ResetPlayerGuiOnSpawn turned off.


Report Abuse
unwarranted is not online. unwarranted
Joined: 05 Jun 2009
Total Posts: 1087
05 Jun 2016 08:57 PM
yea i actually just just moved it into their, with the resetgui turned off, but the problem still persists.


mom wheres the spaghetti
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
05 Jun 2016 08:58 PM
I bet you just have to re-define the Character after the player respawns, because the original one is dying and no longer exists.


Report Abuse
TheBenSquare is not online. TheBenSquare
Joined: 13 Dec 2009
Total Posts: 13604
05 Jun 2016 08:58 PM
Set the 'ResetPlayerGuiOnSpawn' property to true. It'll cause the same issue that the StarterPlayerScripts would cause while it's false.
Report Abuse
unwarranted is not online. unwarranted
Joined: 05 Jun 2009
Total Posts: 1087
05 Jun 2016 09:01 PM
@Soybeen

i tried, but it doesnt appear to work, am i doing it right?
local Player = game.Players.LocalPlayer
local character = Player.Character

Player.CharacterAdded:connect(function(char)
character = char
end)


mom wheres the spaghetti
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
05 Jun 2016 09:03 PM
game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character.Humanoid.HealthChanged:connect(function()
print('test')
end)
end)
end)


Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
05 Jun 2016 09:04 PM
*Use that from a server script, it should work.


Report Abuse
unwarranted is not online. unwarranted
Joined: 05 Jun 2009
Total Posts: 1087
05 Jun 2016 09:04 PM
i need to use a localscript in startergui, due to FE being enabled


mom wheres the spaghetti
Report Abuse
Soybeen is not online. Soybeen
Joined: 17 Feb 2010
Total Posts: 21462
05 Jun 2016 09:08 PM
I encourage you to learn about RemoteEvents so that you can communicate this result to the client :D




Report Abuse
unwarranted is not online. unwarranted
Joined: 05 Jun 2009
Total Posts: 1087
05 Jun 2016 09:09 PM
mmm, so i would use a remoteevent to send the character through to the localscript from the serverscript?


mom wheres the spaghetti
Report Abuse
TheBenSquare is not online. TheBenSquare
Joined: 13 Dec 2009
Total Posts: 13604
05 Jun 2016 09:12 PM
Just to add onto what I already said, the 'ResetPlayerGuiOnSpawn' property will (while it's set as true) replace the player's PlayerGui (which would include any scripts in the PlayerGui) upon the player respawning. So, instead of having to use a CharacterAdded event, you could simply put that local script in the StarterGui and set 'ResetPlayerGuiOnSpawn' to true and it'd have the same effect as the CharacterAdded event, except it'd be local.
Report Abuse
unwarranted is not online. unwarranted
Joined: 05 Jun 2009
Total Posts: 1087
05 Jun 2016 09:13 PM
i know, but i don't want to set it to true due to actually having guis in there i don't want removed


mom wheres the spaghetti
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