While loop ignoring the if statment

I am making a boss fight, but there is one simple bug that just isn’t working. It is ignoring the if statement under the while loop. I have a script that makes the boss constantly rotate around the island until it is venerable.

local monster = script.Parent

local center = Vector3.new(84.073, 77.183, -3937.575) 
local distanceFromCenter = 750
local speed = 0.07
local RunService = game:GetService("RunService")
local function MoveDown()
	while wait(0.1) do
		script.Parent:SetPrimaryPartCFrame(script.Parent:GetPrimaryPartCFrame() * CFrame.new(0,-10,0))
	end
end
while true do
if script.Parent.Parent.VonerableTime.Value == false then -- it just ignores this even when I manualy set it to true
	for i = 0, 360 do
task.wait(speed)
		-- note: cframe angle's x,y,z might need adjusted depending on model orientation.
		monster:PivotTo(CFrame.new(center) * CFrame.Angles(0,math.rad(i),0) * CFrame.new(0,0,distanceFromCenter))
			monster:PivotTo(monster:GetPivot() * CFrame.Angles(0,math.rad(-30),0))
		end
elseif script.Parent.Parent.VonerableTime.Value == true then
	MoveDown()-- once im done, I want him to move under the water. 
	end
end
1 Like

Actually one moment what kind of Instance is VonerableTime?

1 Like

hmm well the script definitely works well it does not ignore the if

2 Likes

Probably a boolValue

Summary

charrrrrrrrrrs

1 Like

The code should work. That’s why I am asking. It’s weird for an Instance named VonerableTime to be a BoolValue (instead of IntValue)

1 Like

For what i can see in the code is something like this
imagen

2 Likes

We need the OP’s hierarchy. He didn’t post enough information.

3 Likes

I just want it to know when it is ready to go under the water, it doesnt need to be a int value.

1 Like

Yep, that is exactly how it looks.

1 Like

¿Can you add this?

The if statement is working perfectly fine so maybe you have another script that is changing the boolvalue

1 Like

I gave you that script, It’s the only script I gave. There is another script that changes the bool value and it works, it just doesn’t check if it changed for some reason under the script I gave.

I assume hes changing the boolvalue to true manually and it will continue to run as if the boolvalue were false.

if he’s changing it manually maybe he’s changing in client side instead of switching to server side in studio’s play test?

2 Likes