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: Script doesn't work when character resets

Previous Thread :: Next Thread 
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
07 Jul 2015 03:35 PM
This script is fully functional until a person dies, then it doesn't work.

player = script.Parent.Parent
player.CharacterAdded:wait()
character1 = player.Character
character1:WaitForChild("Scripts")

character1.Humanoid.MaxHealth = character1.Scripts.CurrentMaxHealth.Value
character1.Humanoid.Health = character1.Scripts.CurrentMaxHealth.Value




character1.Scripts.CurrentMaxHealth.Changed:connect(function(NewValue)
character1.Humanoid.MaxHealth = NewValue
character1.Humanoid.Health = NewValue
end)



I'm assuming its because the character was removed and a new one added with the same name, but I don't know how to work around that.
ᴍʏ ɴɪɢᴀ ғʀᴏᴍ ᴀɴᴏᴛʜᴇʀ ᴡɪɢᴀ
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
07 Jul 2015 03:43 PM
Please
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
07 Jul 2015 03:59 PM
gah

ᴍʏ ɴɪɢᴀ ғʀᴏᴍ ᴀɴᴏᴛʜᴇʀ ᴡɪɢᴀ
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
07 Jul 2015 04:27 PM


ᴍʏ ɴɪɢᴀ ғʀᴏᴍ ᴀɴᴏᴛʜᴇʀ ᴡɪɢᴀ
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
07 Jul 2015 04:32 PM


ᴍʏ ɴɪɢᴀ ғʀᴏᴍ ᴀɴᴏᴛʜᴇʀ ᴡɪɢᴀ
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
07 Jul 2015 05:37 PM
Keep the scripts disabled and clone them into the player. Then you can enable them. When the player dies, clone the disabled scripts into the player and repeat the process


"Talk is cheap. Show me the code." - Linus Torvalds
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
07 Jul 2015 05:56 PM
Tried doing this in another script:

game.Players.PlayerAdded:connect(function(player)
player.CharacterAdded:connect(function(character)
character:WaitForChild("Humanoid").Died:connect(function()
local allah = player.PlayerScripts.LocalScript

wait("8")
local a = allah:Clone()
a.Parent = player.PlayerScripts
allah:Destroy()
print("done")




end)
end)
end)

itll print done but the new script won't work

ᴍʏ ɴɪɢᴀ ғʀᴏᴍ ᴀɴᴏᴛʜᴇʀ ᴡɪɢᴀ
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
07 Jul 2015 05:58 PM
local script*

not

local allah

script makes more sense as a variable since you are using LocalScript

"Talk is cheap. Show me the code." - Linus Torvalds
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
07 Jul 2015 06:01 PM
that doesnt really change anything tho

ᴍʏ ɴɪɢᴀ ғʀᴏᴍ ᴀɴᴏᴛʜᴇʀ ᴡɪɢᴀ
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
07 Jul 2015 10:04 PM


ᴍʏ ɴɪɢᴀ ғʀᴏᴍ ᴀɴᴏᴛʜᴇʀ ᴡɪɢᴀ
Report Abuse
Sevrick is not online. Sevrick
Joined: 22 Oct 2013
Total Posts: 3846
07 Jul 2015 10:06 PM
Ugh...... it's pointless to reply if you won't understand.
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
07 Jul 2015 10:10 PM
Please explain c;

ᴍʏ ɴɪɢᴀ ғʀᴏᴍ ᴀɴᴏᴛʜᴇʀ ᴡɪɢᴀ
Report Abuse
Sevrick is not online. Sevrick
Joined: 22 Oct 2013
Total Posts: 3846
07 Jul 2015 10:19 PM
player = script.Parent.Parent
game.Players.PlayerAdded:connect:function(plr)
plr.CharacterAdded:connect(function(chr)

character1 = chr
character1:WaitForChild("Scripts")

character1.Humanoid.MaxHealth = character1.Scripts.CurrentMaxHealth.Value
character1.Humanoid.Health = character1.Scripts.CurrentMaxHealth.Value




character1.Scripts.CurrentMaxHealth.Changed:connect(function(NewValue)
character1.Humanoid.MaxHealth = NewValue
character1.Humanoid.Health = NewValue

end)
end)
Report Abuse
Sevrick is not online. Sevrick
Joined: 22 Oct 2013
Total Posts: 3846
07 Jul 2015 10:19 PM
--Sorry, remove the player variable.
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
07 Jul 2015 10:23 PM
Works like normal until I reset, still doesnt work when I reset.

ᴍʏ ɴɪɢᴀ ғʀᴏᴍ ᴀɴᴏᴛʜᴇʀ ᴡɪɢᴀ
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
08 Jul 2015 01:42 PM
gah

ᴍʏ ɴɪɢᴀ ғʀᴏᴍ ᴀɴᴏᴛʜᴇʀ ᴡɪɢᴀ
Report Abuse
litalela is not online. litalela
Joined: 30 Mar 2010
Total Posts: 6267
08 Jul 2015 06:07 PM
c;

last try

ᴍʏ ɴɪɢᴀ ғʀᴏᴍ ᴀɴᴏᴛʜᴇʀ ᴡɪɢᴀ
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