I know this is something stupid that I have done but I can’t figure out what it is. The script is supposed to cycle through all the players at the same time, but it does them one by one.
coroutine.wrap(function()
for i, player in pairs(game.Players:GetChildren()) do
if player.Character then
local person = player
local startingpos = person.Character.PrimaryPart.CFrame
print('looped')
local params = RaycastParams.new()
params.FilterDescendantsInstances = {person}
params.FilterType = Enum.RaycastFilterType.Exclude
local beam = workspace:Raycast(person.Character.PrimaryPart.Position,Vector3.new(0,-40,0),params)
local Smasher
local InvisSmasher
if beam then
player:SetAttribute('CanRun',false)
player.Character.Humanoid.WalkSpeed = 10
Smasher = Instance.new('Part',workspace)
local quickveloc = person.Character.PrimaryPart.AssemblyLinearVelocity
Smasher.Shape = Enum.PartType.Cylinder
Smasher.Material = Enum.Material.ForceField
Smasher.Orientation = Vector3.new(0,0,90)
Smasher.Position = person.Character.PrimaryPart.Position + Vector3.new((quickveloc.X),0,(quickveloc.Z)) - Vector3.new(0,beam.Distance,0)
Smasher.Anchored = true
Smasher.Size = Vector3.new(3,80,80)
Smasher.CanCollide = false
Smasher.BrickColor = BrickColor.new('Gold')
InvisSmasher = Instance.new('Part',workspace)
InvisSmasher.Shape = Enum.PartType.Cylinder
InvisSmasher.Transparency = 1
InvisSmasher.Orientation = Vector3.new(0,0,90)
InvisSmasher.Position = Smasher.Position
InvisSmasher.Anchored = true
InvisSmasher.Size = Vector3.new(20,80,80)
InvisSmasher.CanCollide = false
InvisSmasher.CanCollide = false
end
local groundclone = game.ReplicatedStorage.GroundSmash:Clone()
groundclone.Parent = workspace
groundclone:PivotTo(Smasher.CFrame * CFrame.new(Vector3.new(-50,0,0)) * CFrame.Angles(0,0,math.rad(-90)))--(startingpos - Vector3.new(0,50,0))
local TweenService = game:GetService('TweenService')
local part = groundclone.Hitbox
local info = TweenInfo.new(.5,Enum.EasingStyle.Quad,Enum.EasingDirection.Out,0,true,0)
local goal = {CFrame = groundclone.PrimaryPart.CFrame + Vector3.new(0,80,0)}
local Tween = TweenService:Create(part,info,goal)
task.wait(2.5)
script.Swoosh:Play()
task.wait(1.5)
script.RockSmash:Play()
Tween:Play()
player.Character.Humanoid.WalkSpeed = 16
player:SetAttribute('CanRun',true)
local shove
local touching = workspace:GetPartsInPart(InvisSmasher)
for i,v in pairs(touching) do
if v.Parent == person.Character then
v.Parent.Humanoid:TakeDamage(60)
shove = Instance.new("BodyVelocity")
shove.Parent = v.Parent:FindFirstChild("HumanoidRootPart")
v.Parent:FindFirstChild("Humanoid"):ChangeState(Enum.HumanoidStateType.FallingDown)
shove.MaxForce = Vector3.new(1000000,1000000,1000000)
shove.Velocity = Vector3.new(0,300,0)
break
end
end
task.wait(1)
if shove then
shove:Destroy()
end
groundclone:Destroy()
Smasher:Destroy()
InvisSmasher:Destroy()
end
end
task.wait(5)
end)()