What do you want to achieve?
I want to change players gui whenever a boolvalue from server changes
What is the issue?
I want to pass the value using FireAllClients() but somehow the value i pass that is inside brackets is nil?
What solutions have you tried so far?
everything ngl
Script inside ServerScriptService:
local digits = serverStorage.digitsRevealed:GetChildren()
for i, digitValue in pairs(digits) do
digitValue.Changed:Connect(function()
if digitValue.Value == true then
replicatedStorage.Remotes.revealDigit:FireAllClients(digitValue)
end
end)
end
LocalScript inside StarterGui.ScreenGui:
local text_digits = script.Parent.digits:GetChildren()
replicatedStorage.Remotes.revealDigit.OnClientEvent:Connect(function(digitValue)
for i, text in pairs(text_digits) do
if text.Name == digitValue.Name then
text.Text = digitValue.Name
end
end
end)
Are you sending a ServerStorage object to the client? If so it will be nil, since the client cannot access server stored items in ServerStorage or ServerScriptService, try sending the name instead.
SERVER
local digits = serverStorage.digitsRevealed:GetChildren()
for i, digitValue in pairs(digits) do
digitValue.Changed:Connect(function()
if digitValue.Value == true then
replicatedStorage.Remotes.revealDigit:FireAllClients(digitValue.Name)
end
end)
end
CLIENT
local text_digits = script.Parent.digits:GetChildren()
replicatedStorage.Remotes.revealDigit.OnClientEvent:Connect(function(digitValue)
for i, text in pairs(text_digits) do
if text.Name == digitValue then
text.Text = digitValue
end
end
end)