How to send updated data to the client?

I assume there are probably some threads about this topic and I’m pretty sure I’ve made one in the past however how do I send data to the client when I need to update something? When the player first joins my game I send data to the client to like load stuff and display things, but then if the player makes a purchase or something I wanna be able to update their gold frame and in the shop I wanna update the new amount they own etc.

Like what I do is like when the player buys something I just as I do the purchase on the server I fire clients with the new gold cost, but then like yeah idk hopefully this makes sense lol. I thought maybe I could use like metatables and then just like when something inside the players data dictionary changes I can just fire the client and whatever, but i don’t think that would work.

You can use RemoteEvent:FireClient(Player) and RemoteEvents.OnClientEvent to send the new data to a new client and receive it with a localscript.

I would personnaly ask the server from the client to receive the data, and it’ll be more safe!
I’ll use Remote Functions

That’s what I’m using although for some reason the OnClientEvent doesn’t always fire which is really weird.

I have my FireClient and I thought all scripts that have the OnClientEvent (if it’s the same event) would like run, but apparently not I guess? lol.

I have this in one of my scripts

dataEvent:FireClient(player,data)

And then I have this in 2 of my local scripts and yet for some reason, only one of them runs.

dataEvent.OnClientEvent:Connect(function(receivedData)
	goldText.Text = receivedData["gold"]
	data = receivedData
end)
1 Like