We have the following:
If I click on the button, the button will have “Text = True”, if I do the same again, it will have “Text = False”
Code(LocalScript):
local ReplicatedStorage = game:WaitForChild(“ReplicatedStorage”)
script.Parent.Frame.TextButton.MouseButton1Click:Connect(function()
if script.Parent.Frame.TextButton.Text == “True” then
script.Parent.Frame.TextButton.Text = “False”
local f = “False”
ReplicatedStorage.RemoteEvent:FireServer(f)
elseif script.Parent.Frame.TextButton.Text == “False” then
script.Parent.Frame.TextButton.Text = “True”
local f = “True”
ReplicatedStorage.RemoteEvent:FireServer(f)
end
end)
And this value (called “f” will be taken from a local script to a serverscript (via a remote event)
Code(ServerScript1):
while wait(1) do
game.ReplicatedStorage.RemoteEvent.OnServerEvent:Connect(function(plr, f)
if f == “False” then
game.ServerScriptService.Test.Value.Value = “False”
elseif f == “True” then
game.ServerScriptService.Test.Value.Value = “True”
end
end)
end
This is where this script will check if “f” is “True” or “False” and will make the “BoolValue” Located inside ServerScript2 have the respective value assigned
And now ServerScript2 will check if the “BoolValue” is “True” or “False” and will print the corresponding answer below.
Code(ServerScript2):
local ServerScriptService = game:GetService(“ServerScriptService”)
while wait(1) do
if ServerScriptService.Test.Value.Value == true then
print(“nice”)
elseif ServerScriptService.Test.Value.Value == false then
print(“bad”)
end
end
What’s the problem?
As seen here the system works correctly however when I click again the second time the button goes “False” it will simply continue to print “nice” instead of “bad”.
What have I done wrong?
Here is the place:test.rbxl (27.3 KB)