FireAllClients() doesn't pass the value to client?

  1. What do you want to achieve?
    I want to change players gui whenever a boolvalue from server changes

  2. What is the issue?
    I want to pass the value using FireAllClients() but somehow the value i pass that is inside brackets is nil?

  3. 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)

yea, this is what i wanted to do, i forgot that client cant view serverstorage, thanks!

If in the future you need to send multiple things over the remote event you can do it over multiple arguments or in a table.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.