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: localscript help

Previous Thread :: Next Thread 
HuntHello is not online. 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
extremeninjamaster is not online. extremeninjamaster
Joined: 25 Feb 2012
Total Posts: 2570
12 Jul 2015 02:13 PM
Where did you put the localscript?
Report Abuse
vacha is not online. 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
DopeMixtape is not online. DopeMixtape
Joined: 05 Jan 2015
Total Posts: 381
12 Jul 2015 03:08 PM
You should probably have a CharacterAdded Event




Mixtape Coming Out 2020!
Report Abuse
HuntHello is not online. 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 is not online. 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
DopeMixtape is not online. DopeMixtape
Joined: 05 Jan 2015
Total Posts: 381
12 Jul 2015 03:46 PM
Try the character added event.



Mixtape Coming Out 2020!
Report Abuse
strongalphawarrior is not online. strongalphawarrior
Joined: 27 Jun 2011
Total Posts: 1000
12 Jul 2015 03:48 PM
local plr = game.Players.LocalPlayer
plr.CharacterAdded:connect(function()
--Code
end)


-Baheeg
Report Abuse
HuntHello is not online. 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
DopeMixtape is not online. DopeMixtape
Joined: 05 Jan 2015
Total Posts: 381
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
strongalphawarrior is not online. strongalphawarrior
Joined: 27 Jun 2011
Total Posts: 1000
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
DopeMixtape is not online. DopeMixtape
Joined: 05 Jan 2015
Total Posts: 381
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
strongalphawarrior is not online. strongalphawarrior
Joined: 27 Jun 2011
Total Posts: 1000
12 Jul 2015 04:04 PM
In that case yes, but what you typed would not work.


-Baheeg
Report Abuse
strongalphawarrior is not online. strongalphawarrior
Joined: 27 Jun 2011
Total Posts: 1000
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
DopeMixtape is not online. DopeMixtape
Joined: 05 Jan 2015
Total Posts: 381
12 Jul 2015 04:05 PM
I know, my bad, forgot to clarify that.



Mixtape Coming Out 2020!
Report Abuse
hunxrepair is not online. hunxrepair
Joined: 07 Aug 2011
Total Posts: 777
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 is not online. 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
DopeMixtape is not online. DopeMixtape
Joined: 05 Jan 2015
Total Posts: 381
12 Jul 2015 04:17 PM
Did you add the playeradded event above the characteradded?



Mixtape Coming Out 2020!
Report Abuse
HuntHello is not online. HuntHello
Joined: 19 Jan 2011
Total Posts: 577
12 Jul 2015 04:22 PM
actually, playeradded doesn't run in localscripts :(
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
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
DopeMixtape is not online. DopeMixtape
Joined: 05 Jan 2015
Total Posts: 381
12 Jul 2015 04:29 PM
What exactly are you trying to do on the local script?



Mixtape Coming Out 2020!
Report Abuse
DopeMixtape is not online. DopeMixtape
Joined: 05 Jan 2015
Total Posts: 381
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
hunxrepair is not online. hunxrepair
Joined: 07 Aug 2011
Total Posts: 777
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 is not online. 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
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