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
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”)
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