I'm trying to set the rotation of some part when onClicked. Can someone show what I did wrong?
local TweenService = game:GetService("TweenService")
local drawer1 = script.Parent:WaitForChild("Drawer1")
local drawer2 = script.Parent:WaitForChild("Drawer2")
local drawer3 = script.Parent:WaitForChild("Drawer3")
local drawer4 = script.Parent:WaitForChild("Drawer4")
local drawer5 = script.Parent:WaitForChild("Drawer5")
local drawer6 = script.Parent:WaitForChild("Drawer6")
local tweeningInformation = TweenInfo.new(
0.5,
Enum.EasingStyle.Linear,
Enum.EasingDirection.Out,
0,
false,
0
)
local drawer1Open = {CFrame = CFrame.new(31.585, 0.95, -6.635)}
local drawer2Open = {CFrame = CFrame.new(34.555, 0.924, -6.56)}
local drawer3Open = {CFrame = CFrame.new(33.15, 0.924, -8.485)}
local drawer4Open = {CFrame = CFrame.new(33.15, 0.924, -4.685)}
local drawer5Open = {CFrame = CFrame.new(33.13, 0.749, -6.585)}
local drawer6Open = {CFrame = CFrame.new(31.755, 0.924, -6.585)}
local drawer1Close = {CFrame = CFrame.new(34.585, 0.95, -6.635)}
local drawer2Close = {CFrame = CFrame.new(37.555, 0.924, -6.56)}
local drawer3Close = {CFrame = CFrame.new(36.15, 0.924, -8.485)}
local drawer4Close = {CFrame = CFrame.new(36.15, 0.924, -4.685)}
local drawer5Close = {CFrame = CFrame.new(36.13, 0.749, -6.585)}
local drawer6Close = {CFrame = CFrame.new(34.755, 0.924, -6.585)}
local tween1open = TweenService:Create(drawer1,tweeningInformation,drawer1Open)
local tween1close = TweenService:Create(drawer1,tweeningInformation,drawer1Close)
local tween2open = TweenService:Create(drawer2,tweeningInformation,drawer2Open)
local tween2close = TweenService:Create(drawer2,tweeningInformation,drawer2Close)
local tween3open = TweenService:Create(drawer3,tweeningInformation,drawer3Open)
local tween3close = TweenService:Create(drawer3,tweeningInformation,drawer3Close)
local tween4open = TweenService:Create(drawer4,tweeningInformation,drawer4Open)
local tween4close = TweenService:Create(drawer4,tweeningInformation,drawer4Close)
local tween5open = TweenService:Create(drawer5,tweeningInformation,drawer5Open)
local tween5close = TweenService:Create(drawer5,tweeningInformation,drawer5Close)
local tween6open = TweenService:Create(drawer6,tweeningInformation,drawer6Open)
local tween6close = TweenService:Create(drawer6,tweeningInformation,drawer6Close)
local clickdetector = game.Workspace.DrawerModel.Drawer1.ClickDetector
local t = game.Workspace.DrawerModel.Drawer1
local y = game.Workspace.DrawerModel.Drawer2
local u = game.Workspace.DrawerModel.Drawer3
local i = game.Workspace.DrawerModel.Drawer4
local o = game.Workspace.DrawerModel.Drawer5
local p = game.Workspace.DrawerModel.Drawer6
clickdetector.MouseClick:Connect(function()
t.Orientation = CFrame.fromOrientation(0,0,0)
y.Orientation = CFrame.fromOrientation(0,0,0)
u.Orientation = CFrame.fromOrientation(0,90,0)
i.Orientation = CFrame.fromOrientation(0,90,0)
o.Orientation = CFrame.fromOrientation(0,0,-90)
p.Orientation = CFrame.fromOrientation(0,0,0)
tween1open:Play()
tween2open:Play()
tween3open:Play()
tween4open:Play()
tween5open:Play()
tween6open:Play()
wait(2)
tween1close:Play()
tween2close:Play()
tween3close:Play()
tween4close:Play()
tween5close:Play()
tween6close:Play()
end)
clickdetector.MouseClick:connect()
local clickdetector = game.Workspace.DrawerModel.Drawer1.ClickDetector
local t = game.Workspace.DrawerModel.Drawer1
local y = game.Workspace.DrawerModel.Drawer2
local u = game.Workspace.DrawerModel.Drawer3
local i = game.Workspace.DrawerModel.Drawer4
local o = game.Workspace.DrawerModel.Drawer5
local p = game.Workspace.DrawerModel.Drawer6
clickdetector.MouseClick:Connect(function()
t.Orientation = CFrame.fromOrientation(0,0,0)
y.Orientation = CFrame.fromOrientation(0,0,0)
u.Orientation = CFrame.fromOrientation(0,90,0)
i.Orientation = CFrame.fromOrientation(0,90,0)
o.Orientation = CFrame.fromOrientation(0,0,-90)
p.Orientation = CFrame.fromOrientation(0,0,0)
tween1open:Play()
tween2open:Play()
tween3open:Play()
tween4open:Play()
tween5open:Play()
tween6open:Play()
wait(2)
tween1close:Play()
tween2close:Play()
tween3close:Play()
tween4close:Play()
tween5close:Play()
tween6close:Play()
end)
clickdetector.MouseClick:connect()
local clickdetector = game.Workspace.DrawerModel.Drawer1.ClickDetector
local t = game.Workspace.DrawerModel.Drawer1
local y = game.Workspace.DrawerModel.Drawer2
local u = game.Workspace.DrawerModel.Drawer3
local i = game.Workspace.DrawerModel.Drawer4
local o = game.Workspace.DrawerModel.Drawer5
local p = game.Workspace.DrawerModel.Drawer6
clickdetector.MouseClick:Connect(function()
t.Orientation = CFrame.fromOrientation(0,0,0)
y.Orientation = CFrame.fromOrientation(0,0,0)
u.Orientation = CFrame.fromOrientation(0,90,0)
i.Orientation = CFrame.fromOrientation(0,90,0)
o.Orientation = CFrame.fromOrientation(0,0,-90)
p.Orientation = CFrame.fromOrientation(0,0,0)
tween1open:Play()
tween2open:Play()
tween3open:Play()
tween4open:Play()
tween5open:Play()
tween6open:Play()
wait(2)
tween1close:Play()
tween2close:Play()
tween3close:Play()
tween4close:Play()
tween5close:Play()
tween6close:Play()
end)
clickdetector.MouseClick:connect()
local clickdetector = game.Workspace.DrawerModel.Drawer1.ClickDetector
local t = game.Workspace.DrawerModel.Drawer1
local y = game.Workspace.DrawerModel.Drawer2
local u = game.Workspace.DrawerModel.Drawer3
local i = game.Workspace.DrawerModel.Drawer4
local o = game.Workspace.DrawerModel.Drawer5
local p = game.Workspace.DrawerModel.Drawer6
clickdetector.MouseClick:Connect(function()
t.Orientation = CFrame.fromOrientation(0,0,0)
y.Orientation = CFrame.fromOrientation(0,0,0)
u.Orientation = CFrame.fromOrientation(0,90,0)
i.Orientation = CFrame.fromOrientation(0,90,0)
o.Orientation = CFrame.fromOrientation(0,0,-90)
p.Orientation = CFrame.fromOrientation(0,0,0)
tween1open:Play()
tween2open:Play()
tween3open:Play()
tween4open:Play()
tween5open:Play()
tween6open:Play()
wait(2)
tween1close:Play()
tween2close:Play()
tween3close:Play()
tween4close:Play()
tween5close:Play()
tween6close:Play()
end)
clickdetector.MouseClick:connect()
local clickdetector = game.Workspace.DrawerModel.Drawer1.ClickDetector
local t = game.Workspace.DrawerModel.Drawer1
local y = game.Workspace.DrawerModel.Drawer2
local u = game.Workspace.DrawerModel.Drawer3
local i = game.Workspace.DrawerModel.Drawer4
local o = game.Workspace.DrawerModel.Drawer5
local p = game.Workspace.DrawerModel.Drawer6
clickdetector.MouseClick:Connect(function()
t.Orientation = CFrame.fromOrientation(0,0,0)
y.Orientation = CFrame.fromOrientation(0,0,0)
u.Orientation = CFrame.fromOrientation(0,90,0)
i.Orientation = CFrame.fromOrientation(0,90,0)
o.Orientation = CFrame.fromOrientation(0,0,-90)
p.Orientation = CFrame.fromOrientation(0,0,0)
tween1open:Play()
tween2open:Play()
tween3open:Play()
tween4open:Play()
tween5open:Play()
tween6open:Play()
wait(2)
tween1close:Play()
tween2close:Play()
tween3close:Play()
tween4close:Play()
tween5close:Play()
tween6close:Play()
end)
clickdetector.MouseClick:connect()
local clickdetector = game.Workspace.DrawerModel.Drawer1.ClickDetector
local t = game.Workspace.DrawerModel.Drawer1
local y = game.Workspace.DrawerModel.Drawer2
local u = game.Workspace.DrawerModel.Drawer3
local i = game.Workspace.DrawerModel.Drawer4
local o = game.Workspace.DrawerModel.Drawer5
local p = game.Workspace.DrawerModel.Drawer6
clickdetector.MouseClick:Connect(function()
t.Orientation = CFrame.fromOrientation(0,0,0)
y.Orientation = CFrame.fromOrientation(0,0,0)
u.Orientation = CFrame.fromOrientation(0,90,0)
i.Orientation = CFrame.fromOrientation(0,90,0)
o.Orientation = CFrame.fromOrientation(0,0,-90)
p.Orientation = CFrame.fromOrientation(0,0,0)
tween1open:Play()
tween2open:Play()
tween3open:Play()
tween4open:Play()
tween5open:Play()
tween6open:Play()
wait(2)
tween1close:Play()
tween2close:Play()
tween3close:Play()
tween4close:Play()
tween5close:Play()
tween6close:Play()
end)
clickdetector.MouseClick:connect()

2 comments
That's a load of script text. You can always try CFrame.angles.
Moderating because no one wants to look through that much code. +1 to omit rep loss