Bool value detection gone wrong lol

Ok so I have a localscript which contains a for loop that checks if a bool value is false and does something if the bool value is false

However the bool value gets set to false on the server and the check is on the client.
for some odd reason when I set the bool value to false on the server (I print it and it actually sets to false) its still considered true on the client (printing the value and it stays true for some reason)

I’ve done some debugging and
the for loop works
the value sets to false on the server
value stays true on client (its not getting set to true again either)

SERVER SCRIPT: (remote event)
Variable: (char = plr.Character)

local attacking = char.attacking
attacking.Value = false

the actual loop check (CLIENT SCRIPT)

for i = 1,40 do
			wait(.05)
			if not attacking.Value then
				setattack = false
			end
		end

Variable on the client script is just

local attacking = script.Parent.Parent:WaitForChild("attacking")

Yes script.Parent.Parent is the character.

Why don’t you use a .Changed event to check when the boolvalue changes.

Bool.Changed:Connect(function(value)
  print(value
end)
3 Likes

Make sure to add a closing ) to your print :wink:

3 Likes

the value itself simply isn’t changing on the client though despite it being set on the server
its the same bool value too

its not failing to detect
its simply not changing at all when I print the value on the client
it does change on the server however

That doesn’t really make sense. If you change something on the server it will change on the client as well. Is it just that the value isn’t printing that it hasn’t changed, or? Have you tried checking if the value is changing via the instance in workspace?

1 Like

Just did it and it STILL prints as true despite it getting literally set to false.
this is very weird

I did print game.Workspace.(name here).attacking.Value and nothing changed.

I have no clue what to do at this point

If anyone else comes along able to help here is a run down.
Attacking originally gets set to true on the client.
then the client checks to see if attacking gets set to false with a for loop.
the servers sets attacking to false
the client fails to detect it as the value is still true on the client for some reason.

Post a file of the related assets. I’ll have a look.

1 Like

I found the solution.
if you set a value to false while its false it literally does nothing.
since the value is set to true on the client its false on the server
so when I set it to false on the server it detects it as already false and does nothing.
since it does nothing it doesnt replicate to the client.

all I had to do was set it to true before I set it to false.
Thx for all of the help though! :slight_smile: