I am making Momentum Running. I have made the direct running system work, through and proper. The issue reveals itself when I attempt to make a running dust trail whilst the character is running. I have a while true do loop, that breaks on a specific conditional.
Now, the way that the VFX Client gets this is from a FireServer, and two different inputs, being Began, and Ended which hold only true, and false, values that aren’t being changed actively on the client. So, what is happening is leaving me in utter confusion, and it’s not a direct issue related to the Server sending it over.
You see, I have a print inside of the if statement that leads to break, and even though it’s been printed multiple times previously, it’ll continue to play the loop as if the break never existed. Enough talking, here are the scripts.
if input == "W + W" then
if Action and CooldownMod:CheckCD(Player, {"Running"}) == false and BattleModeActive == false then
if IsSprinting then return end
IsSprinting = true
local AlreadyMax = false
local Ran = 0
local ShouldRun = false
InputChecker = Inputs:Check(Enum.KeyCode.W, Player)
Inputs:Insert(Enum.KeyCode.W, Player)
Params = {Player = Player, Held = true}
repeat task.wait(.5)
Ran += 1
if Character.Humanoid.WalkSpeed < MAX_SPEED then
Character.Humanoid.WalkSpeed += 1
print(Ran)
if Ran >= 10 then
if AlreadyMax then continue end
AlreadyMax = true
print("you dirty little boy you just keep printing")
ServerE:FireServer(input, ActionClass, Action, Params)
else
AlreadyMax = false
end
end
until IsSprinting == false or Character.Humanoid.MoveDirection.Magnitude == 0 or UserInputService:IsKeyDown(Enum.KeyCode.W) == nil
Character.Humanoid.WalkSpeed = 13
return
end
end
^InputBegan
if input == "W + W" then
if IsSprinting == false then return end
if IsSprinting then
Character.Humanoid.WalkSpeed = 13
Inputs:Remove(Enum.KeyCode.W, Player)
Params = {Player = Player, Held = false}
ServerE:FireServer(input, ActionClass, Action, Params)
CooldownMod:CreateCooldown(Player, "Running", 1)
return
end
end
InputEnded^
VFX Loop that is giving the issue in question
task.spawn(function()
while true do
if Held ~= true then print("bye") break end
print("cryi' to dat ho", Held)
local raycastResult = workspace:Raycast(arg[3].Position, RayDirection, RayParams)
if raycastResult and raycastResult.Instance then
if Held == false then break end
DustClouds1.Color = ColorSequence.new(raycastResult.Instance.Color or raycastResult.Instance:GetMaterialColor(raycastResult.Material), raycastResult.Instance.Color or raycastResult.Instance:GetMaterialColor(raycastResult.Material))
DustClouds2.Color = ColorSequence.new(raycastResult.Instance.Color or raycastResult.Instance:GetMaterialColor(raycastResult.Material), raycastResult.Instance.Color or raycastResult.Instance:GetMaterialColor(raycastResult.Material))
DustClouds3.Color = ColorSequence.new(raycastResult.Instance.Color or raycastResult.Instance:GetMaterialColor(raycastResult.Material), raycastResult.Instance.Color or raycastResult.Instance:GetMaterialColor(raycastResult.Material))
DustClouds4.Color = ColorSequence.new(raycastResult.Instance.Color or raycastResult.Instance:GetMaterialColor(raycastResult.Material), raycastResult.Instance.Color or raycastResult.Instance:GetMaterialColor(raycastResult.Material))
EmitAll(arg)
end
task.wait(.10)
end
return
end)
Print Debugs and Results: