Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

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

Asked by 8 days ago
Edited 7 days 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 — 7d
0
oh yeah sry techingenius 17 — 7d
0
k i changed it techingenius 17 — 7d
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 — 7d

1 answer

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

Answer this question