HuntHello
|
  |
| Joined: 19 Jan 2011 |
| Total Posts: 577 |
|
|
| 12 Jul 2015 02:12 PM |
I am trying to keep a localscript running even after a character dies, however, it seems like localscripts restart after the character respawns. Does anyone know how to fix this? Thanks!
|
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 02:13 PM |
| Where did you put the localscript? |
|
|
| Report Abuse |
|
|
vacha
|
  |
| Joined: 06 Jan 2011 |
| Total Posts: 1993 |
|
|
| 12 Jul 2015 02:14 PM |
Put it inside "StarterPlayer"
while true do the do |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 03:08 PM |
You should probably have a CharacterAdded Event
Mixtape Coming Out 2020! |
|
|
| Report Abuse |
|
|
HuntHello
|
  |
| Joined: 19 Jan 2011 |
| Total Posts: 577 |
|
|
| 12 Jul 2015 03:39 PM |
| Thanks for the replies. I placed it in StarterGui, and the script activates when someone dies, until 5 seconds after they respawn. Unfortunately, putting it in StarterPlayer doesn't work :( |
|
|
| Report Abuse |
|
|
HuntHello
|
  |
| Joined: 19 Jan 2011 |
| Total Posts: 577 |
|
|
| 12 Jul 2015 03:41 PM |
| Oh yeah also im trying to access currentcamera, however in starterplayer it doesnt work :( |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 03:46 PM |
Try the character added event.
Mixtape Coming Out 2020! |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 03:48 PM |
local plr = game.Players.LocalPlayer plr.CharacterAdded:connect(function() --Code end)
-Baheeg |
|
|
| Report Abuse |
|
|
HuntHello
|
  |
| Joined: 19 Jan 2011 |
| Total Posts: 577 |
|
|
| 12 Jul 2015 03:52 PM |
hmm, here's my code if it will help! The script is in startergui, and activates everytime the player dies.
player = script.Parent.Parent print("running on "..player.Name) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function() local cam = workspace.CurrentCamera local foci = character:FindFirstChild("Head") or 1 --some camera manipulation things that i cant make last after the player has died (because dying = clearing out of startergui)
How should I add characteradded? thanks! |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 03:56 PM |
Well, for example:
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(character) character.Humanoid.WalkSpeed = 25 end) end)
Instead of "character.Humanoid.Walkspeed = 25", you add the rest of your code or something. It just depends on what you want it to do when a character dies
Mixtape Coming Out 2020! |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 03:59 PM |
@Dope if that's from a localscript it would not work even if FilteringEnabled is disabled
-Baheeg |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 04:02 PM |
You could add a Regular script to add the local script to wherever within the player... You know that right?
Mixtape Coming Out 2020! |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 04:04 PM |
In that case yes, but what you typed would not work.
-Baheeg |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 04:04 PM |
In that case yes, but what you typed previously inserted into a localscript would not work*
-Baheeg |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 04:05 PM |
I know, my bad, forgot to clarify that.
Mixtape Coming Out 2020! |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 04:12 PM |
Insert it in StarterPlayer > StarterPlayerScripts script(s) inside here will run and won't be removed upon the player dying |
|
|
| Report Abuse |
|
|
HuntHello
|
  |
| Joined: 19 Jan 2011 |
| Total Posts: 577 |
|
|
| 12 Jul 2015 04:16 PM |
^Thanks, but for some reason in
player = script.Parent.Parent print("running on "..player.Name) player.CharacterAdded:connect(function(character) character:WaitForChild("Humanoid").Died:connect(function()
print runs, but characteradded doesn't |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 04:17 PM |
Did you add the playeradded event above the characteradded?
Mixtape Coming Out 2020! |
|
|
| Report Abuse |
|
|
HuntHello
|
  |
| Joined: 19 Jan 2011 |
| Total Posts: 577 |
|
|
| 12 Jul 2015 04:22 PM |
| actually, playeradded doesn't run in localscripts :( |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 04:26 PM |
"actually, playeradded doesn't run in localscripts :("
If it doesn't run altogether, then that's even better. Maybe people will finally stop using it in LocalScripts. But as far as I know, it just doesn't show the LocalPlayer, OBVIOUSLY because the LocalPlayer needs to be added before LocalScripts will run xD |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 04:29 PM |
What exactly are you trying to do on the local script?
Mixtape Coming Out 2020! |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 04:31 PM |
This is what Info I've gathered so far on what you're trying to do:
game.Players.PlayerAdded:connect(function(player) player.CharacterAdded:connect(function(char) local scriptClone = game.Workspace.LocalScript:Clone() -- Or Wherever you put your Local Script scriptClone.Parent = game.Players:GetPlayerFromCharacter(char) end) end)
Mixtape Coming Out 2020! |
|
|
| Report Abuse |
|
|
|
| 12 Jul 2015 04:36 PM |
also, I didn't read through properly the above but they should work
this works
local Player = game.Players.LocalPlayer
Player.CharacterAdded:connect(function() print("Respawned") end)
make sure you reset |
|
|
| Report Abuse |
|
|
HuntHello
|
  |
| Joined: 19 Jan 2011 |
| Total Posts: 577 |
|
|
| 12 Jul 2015 04:39 PM |
| Thanks guys! With your help I got it to work! |
|
|
| Report Abuse |
|
|