Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

CFrame messing up Angles during process?

Asked by
Qorm 100
9 years ago

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!

0
So is setting the angle resetting the CFrame of the items? Does it work without the angle bit? Spongocardo 1991 — 9y

1 answer

Log in to vote
0
Answered by 9 years ago

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
Ad

Answer this question