So I am making a game with the concept of don’t be crushed by a speeding wall with my own twist, but I’ve run into an issue. So in the game there are multiple tunnels where the walls will be, and I am trying to make it so that every few seconds, the walls come flying down the corridor. The issue is that instead of all the walls coming down at once, one wall moves all the way down then comes back, then the next wall does the same. Basically, instead of doing it all at the same time, the do it one by one.
here is the server script that activates them:
local JimmyModule = require(game.ServerScriptService.JimmyModule)
local ActivateJimmy = game.ReplicatedStorage.Remotes.ActivateJimmy
while wait(10) do
ActivateJimmy:FireAllClients(true, false, false, nil)
for i,v in pairs(game.Workspace.JimmyStuff.Jimmys:GetChildren()) do
JimmyModule.MoveJimmy(v)
end
end
and here is the Jimmy Module that the server script requires:
local JimmyModule = {}
local TS = game:GetService("TweenService")
local CloseInfo = TweenInfo.new(
10, -- length
Enum.EasingStyle.Linear, --EasingStyle
Enum.EasingDirection.Out, -- Easing Direction
0, -- How many times the tween will repeat
false, -- Should the tween repeat?
0 -- Delay between each tween
)
function MoveJimmy(Jimmy, JimmyStart, JimmyEnd, OpenTime)
local openProperties = {
Position = JimmyEnd
}
local closeProperties = {
Position = JimmyStart
}
local OpenInfo = TweenInfo.new(
OpenTime, -- length
Enum.EasingStyle.Linear, --EasingStyle
Enum.EasingDirection.Out, -- Easing Direction
0, -- How many times the tween will repeat
false, -- Should the tween repeat?
0 -- Delay between each tween
)
local OpenTween = TS:Create(Jimmy, OpenInfo, openProperties)
local CloseTween = TS:Create(Jimmy, CloseInfo, closeProperties)
Jimmy.BrickColor = BrickColor.new("Bright red")
if Jimmy:FindFirstChild("Happy") and Jimmy:FindFirstChild("Angry")then
Jimmy.Happy.Transparency = 1
Jimmy.Angry.Transparency = 0
end
OpenTween:Play()
wait(OpenTime)
wait(1)
CloseTween:Play()
wait(10)
Jimmy.BrickColor = BrickColor.new("Lime green")
if Jimmy:FindFirstChild("Happy") and Jimmy:FindFirstChild("Angry")then
Jimmy.Happy.Transparency = 0
Jimmy.Angry.Transparency = 1
end
end
function JimmyModule.MoveJimmy(Jimmy)
local JimmyStart = game.Workspace.JimmyStuff.Start:FindFirstChild(Jimmy.Name.."Start").Position
local JimmyEnd = game.Workspace.JimmyStuff.End:FindFirstChild(Jimmy.Name.."End").Position
local JimmyDistance = (Jimmy.Position - JimmyEnd).Magnitude / 28.15
print(JimmyDistance)
MoveJimmy(Jimmy, JimmyStart, JimmyEnd, JimmyDistance)
end
return JimmyModule
I looked at some other topics and they said to use coroutines but I’m not sure how to use them and when I put them in the server script, whatever was wrapped in it just didn’t run. Thank you if you can help!