My Trap script just makes the part flip onto its side

local TweenService = game:GetService("TweenService")

local Trap = script.Parent


local tweeningInformation = TweenInfo.new(
	
	0.5,
	Enum.EasingStyle.Linear,
	Enum.EasingDirection.Out,
	0,
	false,
	0
)

local Trap1Open = {CFrame = CFrame.new(550.128, 23.317, -569.28)}

local Trap1Close = {CFrame = CFrame.new(550.128, 36.63, -569.28)}

local Trap1open = TweenService:Create(Trap, tweeningInformation, Trap1Open)
local Trap2close = TweenService:Create(Trap, tweeningInformation, Trap1Close)



while true do
	Trap1open:Play()

	wait(2)
	Trap2close:Play()
	wait(1)
	Trap1open:Play()
end

This script is suppose to make the part go up and down. But for some reason it does that but flips on its side. Any help?

It’s because without a orientation passed into CFrame it assumes it’s 0,0,0.

You could pass in a orientation to CFrames,
or if your part is symmetrical you could just re-scale it to have it’s orientation based off of 0,0,0

Pass in a Orientation to the CFrame by

local Trap1Open = {CFrame = CFrame.new(550, 23, -569) * CFrame.Angles(math.rad(x), math.rad(y), math.rad(z))}
1 Like

This is what i got in the output.
18:50:03.221 - Workspace.Trap.Movingscript:16: invalid argument #1 to ‘rad’ (number expected, got nil)

set x, y, z values to something.

Where would i find those? And ty for replying.

Sorry for taking a while
image
Replace x with the first number of Orientation, y with the second, and z with the third.