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?
Yea, but you can make the parts wobble randomly, also each part can have it’s own orbit
ok! If I do it on the clients side, do I put the script in workspace? Or a local script?
It doesn’t really matter, but a local script is probably better
gotchu. In replicated Storage?
I’m pretty sure that local scripts don’t work in ReplicatedStorage so put it somewhere like StarterPlayerScripts
alr. I never understood the difference between starterplayerscripts and startercharacterplayer scripts but I can mess around
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
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)
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)
by refference to the part u mean this game.Workspace.P3
? Should I delete the stuff at the top where I say local part…?
No, you can also use the variables that u made at the top
ok, game.Workspace as refference and P3 as part?
sorry could u answer it real quick?
By reference to the part I mean game.Workspace.P3
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?
Yes, copy the line 4 times to add the other parts
well I duplicated all lines where the P1 was mentioned and it didnt work
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)
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