CFrame not changing in if Statement

Hello, Scripting Support. I once again request your help. I am trying to figure out how to change attachments CFrame using if statements , i already have a script that is supposed to Change the CFrame but it does’t do it with no errors. Here is the script , and its the CFrame of an attachment not a part.

local nyc = game.Workspace:WaitForChild("nycbeam")
local attachment = game.Workspace.nycbeam:WaitForChild("Attachment2")

task.spawn(function()
	while true do
		local deltaTime = game:GetService("RunService").Heartbeat:Wait()
		attachment.WorldCFrame += Vector3.new(0, 0, deltaTime * 0.1)
	end
end)

if attachment.WorldCFrame.Position == Vector3.new(0, 0, -53.498) then
	attachment.CFrame = CFrame.new(0, 0, -55.828) 
end
1 Like

i think it has something to do with your deltaTime
waiting for a heartbeat doesnt return anything i think

2 Likes

Try debugging it, print deltaTime and the new Vector3 you’re making with it.
Maybe with what it prints you’ll be able to find a solution or different method.

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.