Trying to change a BoolValue from a local script not working

I’m trying to change the bool value from false to true and vice versa from a local script. The value is a child of a tool.

This is the code which is inside a local script

RS.gasMaskOn.OnClientEvent:Connect(function()
	gasMask.gasMaskOn.Value = true
end)

RS.gasMaskOff.OnClientEvent:Connect(function()
	gasMask.gasMaskOn.Value = false
end)
2 Likes

This is kinda not really on topic but its useful

Just use one RemoteEvent:

RS.GasMask.OnClientEvent:Connect(function(bool: boolean)
     gasMask.gasMaskOn.Value = bool
end)

Then on a Server Script:

-- For All Players
RS.GasMask:FireAllClients(true)
--for just one player
RS.GasMask:FireClient(Player, true)
--[[
Do note you need the Player when Firing a RemoteEvent From Client -> Server
--]]
-- To Disable
RS.GasMask:FireClient(Player, false)
1 Like

Here’s a helpful article. Localscripts can receive a boolean’s value, and can only change its value under certain conditions.

1 Like

Just did a bit more testing and it appears to be the event. Even after removing the code to change the bool, I put in print("test) and that didn’t work either. The value is also inside a tool which is inside the backpack

Alright, then if you are still having problems with the code, one thing you can consider is looking into how the event is being called / fired. Here is a good link where you can see how to properly receive and fire events from servers / clients. I use this resource a lot!

2 Likes

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