My " Phase 2 " Script dont work

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear!
    Im making a funny maze game with a orange ball that i named " Joe "
    if he receive 500 damage he turns into phase 2 that is when he goes sad
    joe this is phase 1 joe

    this is what he’s supposed to become when on phase 2

  2. What is the issue? Include screenshots / videos if possible!
    Soo like, my script dont seems to detect when he’s 500 health, and thats a problem

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I dont searched on the devforum since i mostly would not find any help for this.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

   local Bob = script.Parent -- his name was bob before
local health = script.Parent.Humanoid.Health
local BobClone = game.ServerStorage.Joe
local BobHeart = Bob.Humanoid
local face = script.Parent.Model.FHead.face
local sadface = script.Parent.Model.FHead.sad

while wait() do
	if health <=500 then
		script.Parent.sadness:Play() -- this is a animation that is supposed to play when he get 500 health
		BobHeart.WalkSpeed = 0
		script.Parent.Model.LeftHand.BrickColor = BrickColor.new("Really red")
		script.Parent.Model.RightHand.BrickColor = BrickColor.new("Really red")
		script.Parent.Model.FHead.BrickColor = BrickColor.new("Really red")
		face.Transparency = 1
		sadface.Transparency = 0
		wait(4)
		BobHeart.WalkSpeed = 25 
	end
end

Please do not ask people to write entire scripts or design entire systems for you. If you can’t answer the three questions above, you should probably pick a different category.

1 Like

You have defined Health in a variable that doesn’t change.

Remove

local health = script.Parent.Humanoid.Health

And replace

if health <=500 then

this with:

if Bob.Humanoid.Health <= 500 then

Though your system could work a little better if you used Humanoid:HealthChanged() function and checked if the health is below 500 instead.

This is if the health I lower or equal to 500 not 0

Try this:

local Bob = script.Parent -- his name was bob before
local humanoid = script.Parent.Humanoid -- removed '.Health'
local BobClone = game.ServerStorage.Joe
local face = script.Parent.Model.FHead.face
local sadface = script.Parent.Model.FHead.sad

humanoid.HealthChanged:Connect(function()
	if humanoid.Health <= 500 then
		script.Parent.sadness:Play() -- this is a animation that is supposed to play when he get 500 health
		humanoid.WalkSpeed = 0
		script.Parent.Model.LeftHand.BrickColor = BrickColor.new("Really red")
		script.Parent.Model.RightHand.BrickColor = BrickColor.new("Really red")
		script.Parent.Model.FHead.BrickColor = BrickColor.new("Really red")
		face.Transparency = 1
		sadface.Transparency = 0
		wait(4)
		humanoid.WalkSpeed = 25 
	end
end)

Get the health with .health will not work as it sets a number the value st that time rather than staying up to date

Well when i write the script i tought that <= 500 would detect 500 health and below

It does but you want to detect if it does not is hurt and you also need to set the health back up

Joe sucessfully got sad, but not on a smooth way, the part that changes his appearance works but the one with animation didnt, needed to remove the animation part to make it work, used BabyNinjaTime edit, joe also didnt got 0 speed and after 4 seconds got 25 speed.

1 Like

actually he stops for 4 second and after that get speed , just no anim