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!

3 comments

0

Is the script that sets the value to true a local script?

0

Yes... Do I need to use remote events? it just seems unnecessary

0

Ah shoot, just tried out remote events and it's fixed now.