I want some code to run when the value of a “BoolValue” is changed in a local script.
The function is not running.
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?
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.
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 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.