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

How do I change/fix this rotating model Script?

Asked by 7 years ago
Edited by M39a9am3R 7 years ago

Hey so, FYI I forgot my account to this website so I just made a random account but any who here's my question:

So I have a rotating script I found from a YouTube video (I can't Script) and it worked for rotating the model in its position however it does not rotate in my wished direction. It's rotating up and down. I wish for it to rotate left and right, 360, non stop. It can do the 360 non stop but it's not in my wanted direction as I said before. Here is the Script:

-- Turning logics.
local function rotateModel(objects, center, new, recurse)
 for _,v in pairs(objects) do
  if v:IsA("BasePart") then
   v.CFrame = new:toWorldSpace(center:toObjectSpace(v.CFrame))
  end
  if recurse then
   rotateModel(v:GetChildren(), center, new, true)
  end
 end
end

-- Set your variables.
local model = script.Parent -- Model to transofrm
local turnSpeed = 1 -- Radians it will turn ever 1/100th of a second
local center = model:GetModelCFrame() -- Center point to turn around

-- Run it constantly.
while true do
 rotateModel(
  model:GetChildren(),
  center,
  center * CFrame.Angles(0,math.rad(turnSpeed),0),
  true
 )
 wait()
end

Thanks if you could help me with this, if you know the answer please answer by putting in the script that would work for this model. (NOTE: Model)

0
Edited for code block. M39a9am3R 3210 — 7y

1 answer

Log in to vote
0
Answered by
Peeshavee 226 Moderation Voter
7 years ago

I am new to scripting as well. But, I think I know enough to answer this. I'll say again though, I'm new, and I'm not sure if this will work. So, at the part where you have:

center * CFrame.angles(0,math.rad(turnSpeed),0)

The CFrame.angles part are the position in which the parts rotate. So what you should do is this:

center * CFrame.angles(math.rad(turnSpeed),0,0)

OR(depending which way you want it to spin)

center * CFrame.angles(0,0,math.rad(turnSpeed))

Hope this helped! If you have questions, feel free to comment below. If it helped, don't forget to accept my answer!

Ad

Answer this question