Making parts organically float

Do you have a part named P1 in workspace?

1 Like
-- When Roblox game loads not everything loads immediately, so if you try to do
:
local Part1 = workspace.Part1

--[[ Then there is a high chance it errors because the part didn' load yet.
To fix this use the WaitForChild function.]]

local Part1 = workspace:WaitForChild("Part1")
1 Like

yep, I sure do, like every other part

you were right, all it took was wait to load

also, Im kinda confused what the numbers behind Orbit are. I am talking about the last function

Screenshot 2023-04-06 152358


one additional question I have is, how to get the floating stuff to stay at its og position. The seconnd pic me in studio, not playing. You can clearly see some things are rotated and are not on the same height scale. On the first pic, all parts are not rotated and are orbiting at the same height scale. How would I fix that?

There are just some random numbers I picked for them to have different time offset, it basically just offsets the time for rotation and noise, for example if P1 had the last number set to 0 and P2 had the last number set to 2 and all the other parameters are the same for them both then after 2 seconds P1 will have the same position as P2 when the game started

oh, ok. Got it. But do you know what to do with the other problem?

You can move and rotate the orbit part until the position of the orbiting part is close to its original position, about the rotation, change the UpdateOrbitPart function to this

local function UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, MovingPart, Orbit, TimeOffset, xRotation, yRotation, zRotation)
	local PartTime = GameTime + TimeOffset
	local RadiusAdd = math.noise(PartTime * NoiseTimeScale) * NoiseSize

	local ActualRadius = Radius + RadiusAdd

	local OrbitTime = PartTime * Speed

	MovingPart.CFrame = Orbit.CFrame * CFrame.new(Vector3.new(math.cos(OrbitTime), 0, math.sin(OrbitTime)) * ActualRadius) * CFrame.fromOrientation(xRotation or 0, yRotation or 0, zRotation or 0)
end

I added 3 new parameters for rotation on X axis, Y axis and Z axis
Now if you need to rotate the part without changing it’s position then just add the last 3 parameters like this

UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, game.Workspace.P1, workspace.Orbit, 0, 0 --[[rotation on X axis]], 0 --[[rotation on Y axis]], 0 --[[rotation on Z axis]])

and change them, if you don’t know what numbers to pick for the rotation, insert a part with the position of the orbiting part and orientation set to 0, 0, 0 then rotate it by how much you want the orbiting part to be rotated and then change the values of the rotation in the function to the orientation of the new part

ty for helping out on the rotation but the position part wont work. See, I have 4 parts so they still would end up on one height, even if tilted, there will prolly be 1 point higher and other lower while its moving, but still not on heir righ place, only 1 part will be. Can I change position like you did with rotation?

Replace the old UpdateOrbitPart function with this new one

local function UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, MovingPart, Orbit, TimeOffset, Position, xRotation, yRotation, zRotation)
	local PartTime = GameTime + TimeOffset
	local RadiusAdd = math.noise(PartTime * NoiseTimeScale) * NoiseSize

	local ActualRadius = Radius + RadiusAdd

	local OrbitTime = PartTime * Speed

	MovingPart.CFrame = Orbit.CFrame * CFrame.new(Vector3.new(math.cos(OrbitTime), 0, math.sin(OrbitTime)) * ActualRadius) * CFrame.fromOrientation(xRotation or 0, yRotation or 0, zRotation or 0) + Position
end

I added a new paramater for the position (the position is a Vector3)
Add it before rotation like this

UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, game.Workspace.P1, workspace.Orbit, 0, Vector3.new(0, 1, 0) --[[change position here]], 0, 0, 0)
1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.