Help With RemoteEvents, Parameters, and GUI

So, essentially, I want to update the text of a TextBox GUI every five seconds with a value from a server script. I’m aware that parameters can solve this issue, but I don’t really know how to implement them correctly in this situation with UI and RemoteEvents, and the fact that I’m very much a beginner of lua doesn’t help either. I’ve provided the code for the feature that I was hoping to make. Whenever I execute the code, the output just states, “Unable to cast value with object”, while referring to line 4 of the server script. Any feedback is very much appreciated!

Server Script Code

local remote = game.ReplicatedStorage.RemoteEvent
value = 5
local function sendstuff(eu)
	remote:FireClient(eu)
end

while true do
	wait(5)
	sendstuff(value)
end

TextBox Code

local gui = script.Parent
local function update(value)
	gui.Text = (value)
end

game.ReplicatedStorage.RemoteEvent.OnClientEvent:Connect(update)

The first parameter of FireClient is always the Player who you are firing the event for. So, you should pass some player in there. Or alternatively, for right now, you can just change it to FireAllClients to not have to pass any player as a parameter, and it will just fire the event for all players in the game.

will become

remote:FireAllClients(eu)
1 Like

I just tried this and it works. Thanks, especially for your explanation of the solution!

1 Like