How To Make Parts Move With One Script

I have a folder with balls in it ad am trying to make them all move with one script. What I am doing is not working. Can someone help?

This script is a normal script in ServerScriptService

local Folder = game.Workspace.Map.Orbs --Location of Orb

local function bindDummy(EachOrb) --Start fuction
	local Main = EachOrb:FindFirstChild("Orb") --Looks for Orb
	while true do
		for i = 1,30 do
			Main.CFrame = Main.CFrame+Vector3.new(0,0.05,0)
			task.wait(0.001)
		end
		for i = 1,30 do
			Main.CFrame = Main.CFrame-Vector3.new(0,0.05,0)
			task.wait(0.001)
		end
	end
end --End function

for _, EachOrb in pairs(Folder:GetChildren()) do -- Bind all existing dummies
	bindDummy(EachOrb)
end --End for
Folder.ChildAdded:Connect(bindDummy) -- Bind all future dummies
10 Likes

Firstly, ServerStorageScripts is not a thing. So, if you mean to say the script is in ServerStorage, the script will not run. It has to be placed in ServerScriptService or Workspace.

I would also use TweenService instead. So your function would look like this:

local Main = EachOrb:FindFirstChild(“Orb”)
local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, math.huge, true)
local tween = TweenService:Create(Main, info, {CFrame = EachOrb.CFrame * CFrame.new(0, 1.5, 0)})
tween:Play()

But make sure to add at the top:

local TweenService = game:GetService(“TweenService”)

6 Likes

I did I meet to say ServerScriptService

4 Likes

Try using the tween service instead. And how is it not working? Is there an error or did something happen that wasn’t supposed to happen?

5 Likes

No errors only one ball is moving and no others

3 Likes

Is it supposed to continue moving in a loop or just move once?

2 Likes

in loops__--------------------

2 Likes

TweenService did not work------

2 Likes

I edited the code above so it should work now

3 Likes

Sorry I didn’t know this before lol. But I just figured out how to add code snippets so here is the whole script:

local TweenService = game:GetService("TweenService")
local Folder = game.Workspace.Map.Orbs --Location of Orb

local function bindDummy(EachOrb) --Start fuction
	local info = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out, math.huge, true)
	local tween = TweenService:Create(EachOrb, info, {CFrame = EachOrb.CFrame * CFrame.new(0, 1.5, 0)})
	tween:Play()
end --End function

for _, EachOrb in pairs(Folder:GetChildren()) do -- Bind all existing dummies
	bindDummy(EachOrb)
end --End for
Folder.ChildAdded:Connect(bindDummy) -- Bind all future dummies

Let me know if it helps! :grinning:

1 Like

That work but can you help me do the something but have them rotating instead

while true do
	script.Parent.Orientation = script.Parent.Orientation + Vector3.new(0,1,0)
	task.wait()
end

If it’s solved mark my previous response as the solution then create a new post so you can add more details. And I’ll check it out.

Ok How To Make Parts Rotate With One Script

1 Like

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