Odd break conditional being true, yet not breaking

Basically I’m making momentum running, and I send out my script whilst the while loop is running on the client alongside checking if the character is at their peak speed. The minute they reach their peak speed, I send out the remoteevent to run my anti-cheat

Client Script:

            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 

Now, on the server if the fireremote runs a loop for the anti, but the issue comes when I release

On the released (which I did not show because I don’t believe the script is that important, unless said otherwise), I fire a false value to the server which in nature should stop and completely render the while loop inactive, yet it’ll continue to play.

Server:

local Velocity --: Vector3
		local HoldingDown = Params.Held
		task.spawn(function()
			
		
			while true do
				print(Params.Held)
				if Params["Player"] == nil or Params.Held == false then print("lol") break end
				
				DeltaTime = tick() - PreviousTime
				PreviousTime = tick()
				CurrentPos = Params["Player"].Character.HumanoidRootPart.Position 
				task.wait(1.5)	
				OldPos = CurrentPos
				CurrentPos = Params["Player"].Character.HumanoidRootPart.Position 
				
				
				print("still running")
				Velocity = (CurrentPos - OldPos)/DeltaTime 
				
				if Params["Player"] == nil or Params.Held == false then print("lol") break end
			end
			return
		end)

image

1 Like

I removed everything in your script except the basic idea:

Params = false
task.spawn(function()


	while true do
		print(Params)
		if Params == false then print("lol") break end


		print("still running")

		if Params == false then print("lol") break end
	end
	return
end)

It runs fine and prints:

false
lol

I can only guess that whatever is changing the value of Params.Held is not being done by the Server. If the Client is changing that value then the Server will ignore the change.

It’s just a guess.

1 Like

Is there a proper way of sending this over since I don’t want to necessarily edit the value on server.

1 Like

Not sure what you mean.

I was saying the Server ignores any changes made by the Client.

The only way to get the Server to respond is to change the value with a Server Script.

You can tell a Client Script to trigger a Remote Event that will be picked up by a Server Script.

1 Like

I mean sending the raw value as it is
image
image

EDIT: nevermind, overall the value just seemed to get changed back into true at some point after I send it over and I’m just unsure at to why anymore.

EDIT: No matter the way I’m seening to go about it, it always seems to lead to the same result which is a print of false for a few seconds, insinuating the break of the loop, yet it just still continues.

1 Like

You setting up the variable twice.

Maybe just do:

local Params = {}

at the top of your script.

Then redefine within your functions as:

Params = {Player = Player, Held = true}

instead of:

local Params = {Player = Player, Held = true} – remove the LOCAL

No change.

The issue still lasts no matter if I setup the variable again.

Scrapped the Anti-Cheat, still dealing with the same issue in a newer post- If statement for break conditional has been reach, loop still continues - Help and Feedback / Scripting Support - Developer Forum | Roblox

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.