Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 4 years ago
Edited 4 years 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 — 4y
0
oh yeah sry techingenius -82 — 4y
0
k i changed it techingenius -82 — 4y
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 — 4y

1 answer

Log in to vote
0
Answered by 4 years 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 — 4y
0
it didn't it only did the function and never got to the if statement techingenius -82 — 4y
Ad

Answer this question