Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

GUI isnt updating players points when they join, I think its a simple fix? [SOLVED]

Asked by 6 years ago
Edited 6 years ago

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?

0
script.Parent.Text = units.Value.."Units" before the unit.Changed should work. Ultimate_Piccolo 201 — 6y
0
Do I put it inside a playerAdded function GottaHaveAFunTime 218 — 6y
0
It wokrs, Ultimate Piccolo and answer so that we can both get some rep ;) you know what I am saying. GottaHaveAFunTime 218 — 6y
0
Oh oops I don't know if I still can answer because it says "answered" Ultimate_Piccolo 201 — 6y
0
Nah its too late now sorry XD GottaHaveAFunTime 218 — 6y

Answer this question