Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

My Brick moving by CFraming doesnt work?

So what happens is, my brick moves every 10 seconds and only by a little bit. It seems like it skips the FOR loop and goes right ahead instead of finishing the function. I dont know whats going on and i need help, please :)

while true do
wait(10)
	if game.Workspace.MainScript.Open == true then
		for i = 0, 55 do
		wait()
		script.Parent.CFrame = script.Parent.CFrame + Vector3.new(0, 0, 0.5)
		end
	end
end

1 comment

1

your problem seems to be line 3. Is "Open" a value type, BoolValue, i mean? If so, after MainScript.Open add .Value

3 answers

You need to index the Value property of ValueObjects to reference it's value! You did not do so on line 3.

--You can just add the wait function in the definition of the while loop
while wait(10) do
	--Index 'Value'. '== true' is redundant.
	if workspace.MainScript.Open.Value then
		for i = 0, 55 do
			wait()
			script.Parent.CFrame = script.Parent.CFrame + Vector3.new(0, 0, 0.5)
		end
	end
end

I believe that it's skipping because ".Open" is not a proper property of a script. If not, maybe it's because the Vector3 portion isn't using "i", so it won't move with the for loop. Anyway, I hope you find the answer!

1 comment

0

MainScript contains a BoolValue called Open

Nevermind I solved the problem by using the for i, v loop :)

This discussion is preserved as it was. New answers, comments, and votes are closed.