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

Why wont this SetPrimaryPartCFrame() script work?

local Sensor1 = script.Parent.S1
local doorl1 = script.Parent.L1
function onTouched(hit)
	for i = 20,0,0.01 do
		doorl1:SetPrimaryPartCFrame(CFrame.new(i, 0, 0))
		wait()
	end
end
Sensor1.Touched:connect(onTouched)

Why doesnt this work? Help please :(

3 comments

0

Are you sure you have a PrimaryPart set to the model?

0

Yes.

0

Try -0.01 instead of 0.01, because if you add 0.01 to 20, it will never reach 20.

1 answer

Your for loop is inversed, wich means you have to do

for i = 20,0,-0.01 do -- Inversed the 0.01 to -0.01 because you have 20,0 instead of 0,20
     doorl1:SetPrimaryPartCFrame(CFrame.new(i, 0, 0))
     wait()
end

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