Ad
Log in to vote
0

Why doesn't my script work when the other one does if statement?

Asked by 7 months ago
Edited 7 months ago

So pretty much I have lots more code but it is this part that doesn't work

if humanoid.Health <= 0 then
                print("why")
                local function work(player)
                    game.ReplicatedStorage.GiveFear:FireServer()
                    print("noob")
                    print(humanoid)
                    print(humanoid.Health)
                end
                print("work")
                work()
            end

However, it does work when you do this

if humanoid.Health >= 0 then
                print("why")
                local function work(player)
                    game.ReplicatedStorage.GiveFear:FireServer()
                    print("noob")
                    print(humanoid)
                    print(humanoid.Health)
                end
                print("work")
                work()
            end

Can someone please explain why and how to fix this.

0
There is no difference between the two scripts. ThePersonWithAPc 30 — 7mo
0
oh yeah sry techingenius -82 — 7mo
0
k i changed it techingenius -82 — 7mo
0
I noticed you have a ":FireServer" Do you have script in your remote event? If so then try adding the "print("worked") Statement inside the Remote Event. manipulativefixation 0 — 7mo

1 answer

Log in to vote
0
Answered by 7 months ago

when the script is executed it checks if the player is dead before starting that local function so if the player is alive the local function will work, put the if statement in the function that should fix.

0
ill try techingenius -82 — 6mo
0
it didn't it only did the function and never got to the if statement techingenius -82 — 6mo
Ad

Answer this question