Rotating a beam around a circle

Hello!

I’ve been trying to rotate these 4 beams around a circle and so far I have no luck with it.

That’s the picture of what I’ve been trying to rotate

I have tried to use this code but no movement has been showing:

local model = game.Workspace.Model

local currentCFrame = model:GetPrimaryPartCFrame()

model:SetPrimaryPartCFrame(currentCFrame * CFrame.Angles(0, math.rad(90), 0))

Any help will be appreciated!

1 Like

I would move this to Scripting Support. Building Support is if you want feedback or need help with a build.

2 Likes

By the looks of it, there is no loop.

local model = game.Workspace.Model

while wait() do
local currentCFrame = model:GetPrimaryPartCFrame()

model:SetPrimaryPartCFrame(currentCFrame * CFrame.Angles(0, math.rad(90), 0))
end

change the values to get your desired speed and next time post in #help-and-feedback:scripting-support as that is the appropriate category for your issue.

1 Like

I put in the code into both of the models that create the beam and it gives me this error:

ContentProvider:PreloadAsync() failed for rbxthumb://type=Asset&id=182451181&w=150&h=150

1 Like

My apologies! I moved the topic into the scripting support section.

Thank you.

That’s strange, try debugging to see if the loop runs and double check if you have a primary part set.

local model = game.Workspace.Model

while wait() do
local currentCFrame = model:GetPrimaryPartCFrame()
print("loop")
model:SetPrimaryPartCFrame(currentCFrame * CFrame.Angles(0, math.rad(90), 0))
end

tell me what it prints then

1 Like

Ahhh so it shows this:

[Model:GetPrimaryCFrame() failed because no PrimaryPart has been set, or the PrimaryPart no longer exists. Please set Model.PrimaryPart before using this.]

Isn’t a PrimaryPart the ones you generate by clicking the Insert > Part at the top of the Home tab-bar? If not what would be considered one?

A model has a “PrimaryPart” Property, It is what the model moves and rotates relative to.

What you want to do is, if you want to make sure you have a part at the very centre of your “beam” (around where it’s going to rotate) , put that part in the model and set the primarypart of the model to that newly made part, Make sure the primarypart is anchored.

The primarypart is not an object. it’s a property.

1 Like

Okay. I grouped all the Parts that create the 4 beams in the picture and created one model out of them.

Then I added this script inside of the model parent:

workspace.Model.PrimaryPart = workspace.Model.Center
local model = game.Workspace.Model

while wait() do
local currentCFrame = model:GetPrimaryPartCFrame()
print("loop")
model:SetPrimaryPartCFrame(currentCFrame * CFrame.Angles(0, math.rad(90), 0))
end

It gives me these errors from last time:

15:57:07.940 - ContentProvider:PreloadAsync() failed for rbxthumb://type=Asset&id=183435411&w=150&h=150

15:57:07.942 - ContentProvider:PreloadAsync() failed for rbxthumb://type=Asset&id=181701651&w=150&h=150

15:57:07.943 - ContentProvider:PreloadAsync() failed for rbxthumb://type=Asset&id=187789986&w=150&h=150

15:57:07.956 - ContentProvider:PreloadAsync() failed for rbxthumb://type=Asset&id=185687363&w=150&h=150

15:57:07.957 - ContentProvider:PreloadAsync() failed for rbxthumb://type=Asset&id=187790284&w=150&h=150

15:57:07.957 - ContentProvider:PreloadAsync() failed for rbxthumb://type=Asset&id=182451181&w=150&h=150

Those errors are not related to what you want to do. they’re normal roblox errors. Did you assign a “PrimaryPart” to the model.

https://gyazo.com/d6a89f839490dab349f75a1d6fde94f6.jpeg

Notice how the primarypart is “Ball”, do you have the same thing (but with different names obviously) on your model?

You can see his assignment in the script. Does the turning and or “loop” print not work or was it just those asset loading errors?

Ah yes you’re right, my bad i didn’t see that.

Yes I have, but do you want the model to only have one Part of the beam or both? The Part that I have selected as the PrimaryPart is the closest to the center circle.

Yeah, I don’t see any turning in-game and “loop” does not print.

Would you mind sending a screenshot of your workspace?

It works just fine for me, I’ve changed the script slightly:

workspace.Model.PrimaryPart = workspace.Model.Center
local model = game.Workspace.Model

while wait() do
local currentCFrame = model:GetPrimaryPartCFrame()
print("loop")
model:SetPrimaryPartCFrame(currentCFrame * CFrame.Angles(0, .1, 0))
end
--change the ".1" if it's too fast or too slow.

beamrotate.rbxl (2.7 MB)

And yes, as @PapaBreadd mentioned, a screenshot would help us better understand the problem

This is the screenshot of all the parts grouped into one model

It seems like the beam is missing a center part from that screenshot unless i cant see it.

Inside the workspace? Then heres a closer shot

Can you click on the model and send a screenshot of the properties?