Bool Value doesn't turn to false

it turn to true just fine but it doesn’t turn back to false

game.ReplicatedStorage.Delete.DeleteMult.OnServerEvent:Connect(function(plr,value)
	
	if value.Deleating.Value == false then

		value.ImageButton1.Visible = true
		value.Deleating.Value = true
	else
		print("yes")
		value.ImageButton1.Visible = false
		value.Deleating.Value = false


	end
	
end)


Could you give a little more details on your problem?

as i said when i press a button the value turns to true just fine but when i press again it doesn’t turn back to false it don’t even print the “Yes”

I would instead use an else-if statement.

Be more specific.

Would it be possible for you to show up the client script? At the very least, could you show us what value is?

It may also have to do with the parameters?

value is the directory to the original value

local script:

script.Parent.MouseButton1Click:Connect(function()

if script.Parent.Parent.Equipped.Value == false and game.Players.LocalPlayer.Inventory.Multi.Value == true then
   	local value =  script.Parent.Parent
game.ReplicatedStorage.Delete.DeleteMult:FireServer(value)


   end

end)

is this value a boolean?

you may accidentally be setting the value to another nonboolean value in another script.

yes i am sure of it because it turns to true

I’m not sure to be honest. Looks like it should work.

The most likely thing is that maybe you are sending the wrong data the second time around? Maybe you’re changing it elsewhere on accident? If possible, it might be helpful to include your client side code as well.

Also one cool thing about flipping booleans is that you can simplify it down to this instead of using if statements.

game.ReplicatedStorage.Delete.DeleteMult.OnServerEvent:Connect(function(plr,value)
    value.Deleating.Value = not value.Deleating.Value
	value.ImageButton1.Visible = value.Deleating.Value
end)
1 Like

Never mind about sending local code, just saw that post. Totally missed it.

Is it possible that the remote isn’t firing once you change the value to true? Maybe try adding a print statement in your server sided code on the first line after OnServerEvent and seeing if it’s firing. I’m not too sure on how your system works and if something else happens once that value is set to true that would prevent it from being sent, so it’s not for sure but something to try. Maybe the if statement on the client is preventing it from firing after it’s been set to true.

Before you evaluate what value is, try printing it out.

This way you can figure what’s causing the problem. the IF statement, or the event.

I’m not sure the server script can actually reference what you are sending. I don’t generally change gui stuff from the server. It’s generally best to change it from a local script since the player can do that anyways. Going through the server will just cause unnecessary lag and might be the cause of your problem. Put it in your local script and tell the server of the change if necessary.

Basically change your local script to this

script.Parent.MouseButton1Click:Connect(function()

if script.Parent.Parent.Equipped.Value == false and game.Players.LocalPlayer.Inventory.Multi.Value == true then
   	local value =  script.Parent.Parent
    value.Deleating.Value = not value.Deleating.Value
	value.ImageButton1.Visible = value.Deleating.Value
    --game.replicatedstorage.delete.deletemult:FireServer(value) --Tell the server what the new value is if necessary
   end
end)

And remove that part of your server script since the local script handles it now.

It’s pretty obvious as to why it doesn’t work…
You’re only firing the RemoteEvent if the value is false.

i actually found the error and it was a problem of the button when i changed the directory on another button it started working