I made a coroutine so that I can create a seperate line of code that preforms a task for me, so that the next line of code after that does not have to yield what its doing due to the multiple task.wait()
's being used.
How would I put in arguments to a coroutine?
Here’s the code
function effect(marble)
local particle = RainbowParticle:Clone()
particle.Parent = marble
task.wait(2)
particle.Enabled = false
game:GetService("Debris"):AddItem(particle, 12)
end
local effectRoutine = coroutine.create(effect)
local Velocity = Instance.new("BodyAngularVelocity")
Velocity.Parent = marble
local Hum = char:WaitForChild("Humanoid")
local Weld = Instance.new("Weld")
Weld.Parent = marble
Weld.Part0 = root
Weld.Part1 = marble
Hum.PlatformStand = true
coroutine.resume(effectRoutine)
while task.wait() do
if marble then
marble:WaitForChild("BodyAngularVelocity").AngularVelocity = Vector3.new(char.Humanoid.MoveDirection.z * 48, 0, char.Humanoid.MoveDirection.x * -48)
marble:WaitForChild("BodyAngularVelocity").MaxTorque = Vector3.new(30000,30000,30000)
if char.Humanoid.MoveDirection == Vector3.new(0,0,0) then
marble:WaitForChild("BodyAngularVelocity").MaxTorque = Vector3.new(0,0,0)
end
elseif not marble then
break
end
end