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

Why my value is true now, but it still pass while Value == false do???

Asked by 5 years ago
local Noob = script.Parent
local Part = workspace.Part
local Part2 = workspace.Part1
local Fighting = script.Parent.FoundPlayer.Value
----------------------------
while Fighting == false do
    print("Still...")
    if Fighting == false then
        Noob.Humanoid:MoveTo(Part.Position)
        Noob.Humanoid.MoveToFinished:wait()
    end
    if Fighting == false then
        Noob.Humanoid:MoveTo(Part2.Position)
        Noob.Humanoid.MoveToFinished:wait()
    end
end

I have another script to control Fighting, But i think it's unnecessary to put it.
Then that is by question, Why this code still running?

1 answer

Log in to vote
1
Answered by
fredfishy 833 Moderation Voter
5 years ago

If you set Fighting to script.Parent.FoundPlayer.Value, you set it to the literal value at that present time, rather than setting it to "Whatever the value is".

local Noob = script.Parent
local Part = workspace.Part
local Part2 = workspace.Part1
local Fighting = script.Parent.FoundPlayer -- Reference the BooleanValue instance, rather than the value
----------------------------
while Fighting.Value == false do -- Reference the value from the instance
    print("Still...")
    if Fighting.Value == false then -- Reference the value from the instance
        Noob.Humanoid:MoveTo(Part.Position)
        Noob.Humanoid.MoveToFinished:wait()
    end
    if Fighting.Value == false then -- Reference the value from the instance
        Noob.Humanoid:MoveTo(Part2.Position)
        Noob.Humanoid.MoveToFinished:wait()
    end
end
0
Ooh~ Damn it Lua! Thanks for help!!! MEndermanM 73 — 5y
Ad

Answer this question