The code is supposed to open a drawer inside a nightstand. When the Model is rotated at (0,0,0) the code works as intended. When I rotate the model to (0, 90, 0) the code rotates the Drawer back to (0, 0, 0)
I need the model to be able to be place anywhere on a map and be rotated at any angle and still function as intended. I plan on reusing this model across the map and do not want to have to change the position for every Drawer.
script.Parent.DrawerOpen.Value = false
script.Parent.ClickDetector.MouseClick:connect(function(OpenDrawer)
if script.Parent.DrawerOpen.Value == false then
script.Parent.CFrame = CFrame.new(script.Parent.Position + (script.Parent.CFrame.lookVector * -1))
script.Parent.DrawerOpen.Value = true
else if script.Parent.DrawerOpen.Value == true then
script.Parent.CFrame = CFrame.new(script.Parent.Position + (script.Parent.CFrame.lookVector * 1))
script.Parent.DrawerOpen.Value = false
end
end
end)
Thanks!
