Making parts organically float

aha so its a bit like our solar system? If I understood creectly, now it’s like you have 1 part around which the other parts are orbiting or am I wrong?

1 Like

Yea, but you can make the parts wobble randomly, also each part can have it’s own orbit

1 Like

ok! If I do it on the clients side, do I put the script in workspace? Or a local script?

1 Like

It doesn’t really matter, but a local script is probably better

1 Like

gotchu. In replicated Storage?

I’m pretty sure that local scripts don’t work in ReplicatedStorage so put it somewhere like StarterPlayerScripts

1 Like

alr. I never understood the difference between starterplayerscripts and startercharacterplayer scripts but I can mess around

1 Like

The difference between StarterPlayerScripts and StarterCharacterScripts is that the scripts inside of StarterCharacterScripts will be inside of the character of the player, so they will only run when the player character spawns and they will also run again every time the player dies but the scripts that are inside of StarterPlayerScripts will be inside of the PlayerScripts folder inside of the player and don’t require the player character to spawn in order to work, they will also not run again every time the player character dies

3 Likes

Actually, how would I refference all the parts in the function?

local P1 = game.Workspace.P1
local P2 = game.Workspace.P2
local P3 = game.Workspace.P3
local P4 = game.Workspace.P4
local RunService = game:GetService("RunService")
local GameTime = 0

local Radius = 16
local NoiseSize = 6
local NoiseTimeScale = 1
local Speed = 1

local function UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, MovingPart, Orbit)
   local RadiusAdd = math.noise(GameTime * NoiseTimeScale) * NoiseSize

   local ActualRadius = Radius + RadiusAdd

   local OrbitTime = GameTime * Speed

   MovingPart.CFrame = Orbit.CFrame * CFrame.new(Vector3.new(math.cos(OrbitTime), 0, math.sin(OrbitTime)) * ActualRadius)
end

RunService.Heartbeat:Connect(function(dt)
   GameTime += dt

   UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, workspace.MovingPart, workspace.Orbit)
end)
1 Like

Put the part that you want to orbit around another part in the 5th parameter of the function and the part which the other part orbits around as the 6th parameter of the function like this
Also the function should be inside of the RunService.Heartbeat event

UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, Reference to part, The part that it orbits around)
1 Like

by refference to the part u mean this game.Workspace.P3? Should I delete the stuff at the top where I say local part…?

1 Like

No, you can also use the variables that u made at the top

1 Like

ok, game.Workspace as refference and P3 as part?

1 Like

sorry could u answer it real quick?

1 Like

By reference to the part I mean game.Workspace.P3

1 Like
local Orbit = game.Workspace.Orbit
local RunService = game:GetService("RunService")
local GameTime = 0

local Radius = 16
local NoiseSize = 6
local NoiseTimeScale = 1
local Speed = 1

local function UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, P1, Orbit)
	local RadiusAdd = math.noise(GameTime * NoiseTimeScale) * NoiseSize

	local ActualRadius = Radius + RadiusAdd

	local OrbitTime = GameTime * Speed

	P1.CFrame = Orbit.CFrame * CFrame.new(Vector3.new(math.cos(OrbitTime), 0, math.sin(OrbitTime)) * ActualRadius)
end

RunService.Heartbeat:Connect(function(dt)
	GameTime += dt

	UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, game.Workspace.P1, workspace.Orbit)
end)

is the script for now. If I wanna add the other parts would I just copy that line with th referencing 4 times?

1 Like

Yes, copy the line 4 times to add the other parts

1 Like

well I duplicated all lines where the P1 was mentioned and it didnt work :confused:

1 Like

Have you changed the parts in the copied functions?
Also I made an updated function to make sure that if parts have the same NoiseTimeScale then they can still be differently positioned, I added a new TimeOffset paramater in the function, every time you copy the function change the 7th parameter to something different

Replace the old function with this new function

local function UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, MovingPart, Orbit, TimeOffset)
	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)
end

With the new UpdateOrbitPart function the whole code should look something like this

local RunService = game:GetService("RunService")
local GameTime = 0

local Radius = 16
local NoiseSize = 6
local NoiseTimeScale = 1
local Speed = 1

local function UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, MovingPart, Orbit, TimeOffset)
	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)
end

RunService.Heartbeat:Connect(function(dt)
	GameTime += dt

	UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, game.Workspace.P1, workspace.Orbit, 0)
	UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, game.Workspace.P2, workspace.Orbit, 861)
	UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, game.Workspace.P3, workspace.Orbit, 398)
	UpdateOrbitPart(Radius, NoiseSize, NoiseTimeScale, Speed, game.Workspace.P4, workspace.Orbit, -487)
end)
1 Like

Ty, works amazing but I get this error : P1 is not a valid member of Workspace “Workspace” ususally ik why it appears but in this case I dont know how to fix it

1 Like