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

BoolValue is set to true, script says it isn't? [Self-Solved]

Asked by 4 years ago
Edited 4 years ago

Hello!

So I'm making a game where I want to check if an object is within a certain distance and if a boolvalue is set to true. The checking the certain distance is working fine, but the boolvalue part is not. Here's my script:

while true do
    if (script.Parent.hit.Position - workspace.A.Position).Magnitude < 5 then
        print("nearby")
        if workspace.A:FindFirstChild("Active").Value == true then
            print("Hit!")
        else
            print("Failed to Hit")
        end
    end
    wait(0.01)
end

It prints out "nearby" and "failed to hit" EVEN when I can visibly see in the properties of the value that it is true. So I tried disabling the script that sets the boolvalue to true and setting it to true in the editor myself, and when I hit play, It worked perfectly. I feel like the answer is close, but I can't quite get it right.

Any help towards fixing this is appreciated.

Thanks!

0
Is the script that sets the value to true a local script? Raccoonyz 1092 — 4y
0
Yes... Do I need to use remote events? it just seems unnecessary proqrammed 285 — 4y
0
Ah shoot, just tried out remote events and it's fixed now. proqrammed 285 — 4y

Answer this question