Fire BindableEvent when any BoolValue changes in a folder

Hi, I want to detect when any BoolValues property changes in a folder, then fire a BindableEvent.

This is a continuation from: Is there a more effective way to detect when any BoolValues property changes in a folder? - Help and Feedback / Scripting Support - DevForum | Roblox as the solution didn’t work for me.
Please read it as it includes everything you need to know.

Here’s the script in ServerScriptService with the Bindable Event:

local repStorage = game:GetService("ReplicatedStorage")
local bindEvent = repStorage:FindFirstChild("Bindable").Events.ValueChanged
local players = game:GetService("Players")

players.PlayerAdded:Connect(function(player)
bindEvent.Event:Connect(function()
print("Bindable Event")
end)
end)

Ask as many questions as you’d like, any help would be appreciated!

If I understand this correct you want to check within a folder

On the server?

or

On the Client?

that a boolvalue’s value has been changed and fire a bindableEvent to listen and react?

1 Like

Video

Scripts used in the video[to be used as examples]:

S1
game:GetService("Players").PlayerAdded:Connect(function(plr)
	
	local f = Instance.new("Folder", plr)
	f.Name = "BoolFolder"
	
	Instance.new("BoolValue", f).Name = "_1"
	Instance.new("BoolValue", f).Name = "_2"
	Instance.new("BoolValue", f).Name = "_3"
	Instance.new("BoolValue", f).Name = "_4"
end)

game:GetService("ReplicatedStorage").BE.Event:Connect(function(...)
	
	warn(...)
end)
InstanceMaker
game:GetService("Players").PlayerAdded:Connect(function(plr)
	
	local remote = game:GetService("ReplicatedStorage").BE
	
	task.wait(3)
	
	for i,v in pairs(plr:FindFirstChildWhichIsA("Folder"):GetChildren()) do
		
		v.Changed:Connect(function()
			
			remote:Fire(v.Name .. ": value has been changed to [" .. tostring(v.Value) .. "]")
		end)
		
	end
	
end)
1 Like
-- in the script where you want to detect and fire changes

for _,v in pairs(folder:GetChildren()) do
	if v:IsA("BoolValue") then
		v:GetPropertyChangedSignal("Value"):Connect(function()
			bindableEvent:Fire()
		end)
	end
end

-- in another script

bindableEvent.Event:Connect(function()
	print("a boolvalue changed")
end)

-- pass the v in the loop with fire() if you want to get what boolvalue changed
1 Like

Hi a19_9, I haven’t managed to get it to work, I think there’s something wrong with my scripts. Thank you for this, I’m sure it does work, I just need to change a few things. If I could mark 2 replies as a solution, I would. Sorry, Cloud_Emmie replied earlier so I think it’s fair that I give them the solution but thank you so much for your help!

1 Like