So I am trying to make a anchor spin around a fixed part. I got it to do that with this script:
local object = script.Parent
local hinge = script.Parent.Parent.hingestorage:FindFirstChild("hinge")
local speed = 12 -- Speed the anchor spins at.
local hingepos = hinge.Position
script.Parent.Touched:Connect(function(touch)
print(touch.Parent)
if touch.Parent and touch.Parent:FindFirstChild("Humanoid") then
touch.Parent.Humanoid.Sit = true
end
end)
while true do
for i = 1, 360, speed do
object.CFrame = CFrame.new(hingepos) * CFrame.Angles(0,0,math.rad(i)) * CFrame.new(0, 8, 0)
object.Orientation = object.Orientation + Vector3.new(0, 0, 180)
wait(0.1)
end
end
https://gyazo.com/58d2685cee96dcafa1d8fb8d0436aa90 (Video of it working)
But say for example I want to change the y orientation to 90,
local object = script.Parent
local hinge = script.Parent.Parent.hingestorage:FindFirstChild("hinge")
local speed = 12 -- Speed the anchor spins at.
local hingepos = hinge.Position
script.Parent.Touched:Connect(function(touch)
print(touch.Parent)
if touch.Parent and touch.Parent:FindFirstChild("Humanoid") then
touch.Parent.Humanoid.Sit = true
end
end)
while true do
for i = 1, 360, speed do
object.CFrame = CFrame.new(hingepos) * CFrame.Angles(0,0,math.rad(i)) * CFrame.new(0, 8, 0)
object.Orientation = object.Orientation + Vector3.new(0, -90, 180)
wait(0.1)
end
end
it just doesn't do that. Instead of just rotating it by 90, it just turns really weirdly. I don't know how to describe it so here.
https://gyazo.com/3f8ffa8224dd7ea2a01feed5c82d9f42
In the video, you can see it turns -90 degrees, but then it starts to orbit around the hinge instead of turning on it if that makes sense.
Any help would be appreciated!
