but my question is why it would not work to begin with, the script seems just fine and would work the same way with the changed event
and also fyi, the script is cloned from another script then parented to the player, but i dont think that will help with anything
There doesn’t seem to be anything wrong with your code; however I do notice that the health Value (when not regenerating) will be at 101 and the value will regenerate even when it’s 0 (though, as you implied, that might be intended since you’re making your own custom-type health system).
When you clone the script from another script, are you changing the script.Disabled property? The template script should be disabled, but when you clone it to the player, it should be enabled.
yes but i think i had this problem before and some guy told me its because you cant say one value is equal and less than this number and greater and equal to this other number because that would not make sense
I don’t know the context in which your previous problem occurred, but I can tell you that the conditional you wrote in this scenario makes 100% sense. The code in the if statement fires when the value is between 0 and 100 (inclusive). I see nothing wrong with that.
well you can take a look at this topic but i cant put the same problem solution together with this one because it wont work
https://devforum.roblox.com/t/script-not-running-despite-no-errors/1555275
well i this point i remade the script to be something simpler and guranteed to work but it still refuses to work for some reason, which could lead me to think, do scripts even work in the player instance?
That’s different. You were checking to see if the ClockTime was less than a low number but ALSO greater than a higher number, which makes no sense. Here you’re checking to see if the value is lower than a HIGH number and greater than a LOW number, which does make sense.
Can I see the script that clones this script into the player along with the explorer window?
Yes, scripts do work in the player instance.
but heres the script
while true do
if script.Parent.SubHealth.Value <= 100 then
script.Parent.SubHealth.Value = script.Parent.SubHealth.Value + 1
wait(0.5)
end
wait()
end
it still refuses to work for some reason despite no error
i changed the name of the custom health btw
Can I see the script that clones this script into the player along with the explorer window?
how do you take a snap of the window
Try looking up the screenshot shortcut for your computer.
If you’re on a Windows PC I can help you out.
it starts in the core script disabled, which inside the core script it clones the script then parents it to the player instance
then when the script is parented to the player instance, it is activated and does not work despite no errors
I actually don’t know what to say but, this can be the solution. Also parent it to ‘StarterCharacterScripts’
while true do
if not script.Parent.Health.Value == 100 then
print("regening")
script.Parent.Health.Value = script.Parent.Health.Value + 1
task.wait(0.5)
end
task.wait()
end
it works the same way as my script so it did not work as well
Parent it to StarterCharacterScripts and define the Humanoid.
I have figured it out. You were correct. The script seems to not work when it’s an instance within the player. My apologies.
but i thought that in the beginning, so what i did is put it in the character insatnce itstead but that still did not work, which instead it strangely just force deletes the script unless it errors
wait i believe its because it has to be in startercharacterscripts, am i correct?