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

CFrame messing up Angles during process?

So I made this script for my door which slides upwards, however; it resets the position if it moves at all.

q=script.Parent.Parent:GetChildren()
x=script.Parent.Parent.Parent.doortrigger:GetChildren()

debounce=false
function onTouch()
	if debounce==false then
		debounce=true
	for o=1,30 do
		for i,v in pairs(q) do
		v.CFrame=CFrame.new(v.CFrame.x,v.CFrame.y+0.25,v.CFrame.z)
		-- v.CFrame=CFrame.fromEulerAnglesXYZ.new(0,90,0) <-- this doesnt work
		end
		wait()
	end
	wait(2.25)
	for o=1,30 do
	for i,v in pairs(q) do
	v.CFrame=CFrame.new(v.CFrame.x,v.CFrame.y-0.25,v.CFrame.z)
	end
	wait()
	end
	wait(0.8)
	debounce=false
	end end

x[1].Touched:connect(onTouch)
x[2].Touched:connect(onTouch)

I know there is a simple way of fixing this. But I can't find it on the internet apparently )': Help would be appreciated!

1 comment

0

So is setting the angle resetting the CFrame of the items? Does it work without the angle bit?

1 answer

CFrame works like this:

Workspace.Part.CFrame=CFrame.new(0,0,0)*CFrame.fromEulerAnglesXYZ(0,math.pi,0)
--You need the cframe position, then a * then the angles
--btw the Workspace.Part is just an example

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