Hello, I’m trying to make a currency system and I’m trying to make the currency handler edit the text from a players client and I’m not really sure how to do it.
It’s currently only on leaderstats only and I wanna switch it to a GUI.
local DataStoreService = game:GetService("DataStoreService")
local CurrencyStore = DataStoreService:GetDataStore("CurrencyStore")
local Players = game:GetService("Players")
local player = Players.LocalPlayer
Players.PlayerAdded:Connect(function(Player)
local UserId = Player.UserId
local UserName = Player.Name
local Currency = CurrencyStore:GetAsync(UserId)
if Currency == nil then
Currency = 0
CurrencyStore:SetAsync(UserId, Currency)
end
local Leaderstats = Instance.new("Folder", Player)
Leaderstats.Name = "leaderstats"
local Coins = Instance.new("IntValue", Leaderstats)
Coins.Name = "Coins"
Coins.Value = Currency
UserName.PlayerGui.ScreenGui.Coins.Text = Currency
Coins.Changed:Connect(function(NewValue)
CurrencyStore:SetAsync(UserId, NewValue)
UserName.PlayerGui.ScreenGui.Coins.Text = NewValue
end)
end)