Function connected to an event not running in a local script. RemoteEvents not working in a local script too

  1. I want some code to run when the value of a “BoolValue” is changed in a local script.

  2. The function is not running.

  3. I tried:

  • Event .Changed. It didn’t work.
  • Firing a client with a RemoteEvent
  • Asking other devs - they had no idea on how to fix it
game:GetService("ReplicatedStorage").GameIsON.Changed:Connect(function()
	print("CHANGED!") -- Didn't work
end)

and

--SERVER
local remotes = game:GetService("ReplicatedStorage").Remotes

for i,v in pairs(game.Players:GetPlayers()) do
	remotes.ChangeIt:FireClient(v)
end

--CLIENT

local remotes = game:GetService("ReplicatedStorage").Remotes

remotes.ChangeIt.OnClientEvent:Connect(function()
	print("CHANGED!")
end)

I have no idea how to fix this and why is this even a thing. Maybe I am forgetting something?

Why do you have to do, for i, v in pairs. Can’t you just fire all the clients?

1 Like

Ohh, I can… Thanks.
That didn’t solve my problem tho.

Why isn’t working? (It (Value) DEFINITELY changes from the server, I did it manually, just to be sure.)

Is there any output, and did you check while play testing in the explorer if it changed, on both the client and the server.

I think they did change. One sec, let me try it out one more time.

The only reason I can think of on the top of my head that may be why this isn’t running is that the scripts are somewhere in a place where they won’t run. Where is your script parented to?

Ok, I am VERY confused now. In this black, new place - it works, but in my game - it doesn’t. In my game the event is the first thing in the script, so there is no way that is getting blocked by a loop or something.

StarterGui. (Then, obviously - PlayerGui)

I think you should put the script in replicated storage.

No types of scripts will run there. Server scripts run in Workspace and ServerScriptService, and LocalScripts will run in ReplicatedFirst, a player’s PlayerGui, a player’s Backpack, a player’s PlayerScripts, and the player’s character.

I think you should put it in replicated first, make sure to check the value has changed on both the client and the server.

I am a bit unlucky. I think RBX is having some problems rn - I got logged out. But I think if it ran on a blank place, it will run in my game too. I am sure I messed something up. Thanks a lot for your time guys.

I tested your code, and it works for me. I put the LocalScript in StarterPlayerScripts and I put the server Script in ServerScriptService.