I have a GUI that shows you how much Units you have (Units being the ingame currency).

The GUI that shows your units updates only when the value changes, and I was wondering if when a player join if it is possible to update there units based on there units value.

But no matter what I did it didnt error, nor did it work.

Units are stored under Replicated Storage.DataFile[player.Name].Units

Heres the GUI script, its located under a surfaceGui in starterGui

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local player = game.Players.LocalPlayer

local dataFile = ReplicatedStorage:WaitForChild("DataFile")
local playerName = dataFile[player.Name]
local units = playerName:WaitForChild("Units")

units.Changed:connect(function(newValue)
	script.Parent.Text = tostring(newValue) .. " UNITS"
end)

Thank you for your time, again the script updates but only when the value changes so when players first join it says they have 0 Units because the value hasnt changed yet. So is there anyway it can get the units when a player join and update them there also?

5 comments

0

script.Parent.Text = units.Value.."Units" before the unit.Changed should work.

0

Do I put it inside a playerAdded function

0

It wokrs, Ultimate Piccolo and answer so that we can both get some rep ;) you know what I am saying.

0

Oh oops I don't know if I still can answer because it says "answered"

0

Nah its too late now sorry XD