|
| 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
|
  |
| 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 |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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
|
  |
| 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
|
  |
| Joined: 17 Feb 2010 |
| Total Posts: 21462 |
|
|
| 05 Jun 2016 09:04 PM |
*Use that from a server script, it should work.
|
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|
|
| 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 |
|
|