I want the Gui to show the Credit Count for the local player. I have the Gui in Starter Gui with this script:
local player = game.Players.LocalPlayer
local display = script.Parent.Text
local Credits = player.StatStorage.Credits
display = "You Have "..Credits.Value.." Credits Left."
print("Displayed "..player.UserId.."'s Credit Balance of "..Credits.Value)
Credits.Changed:connect(function()
print("Value Changed")
display = "You Have "..Credits.Value.." Credits Left."
print("Displayed "..player.UserId.."'s Credit Balance of "..Credits.Value)
end)
I first tried changing it from the datastore script but without success so I took it out (making the one above).
Here is the DataStore for it:
local DataStore = game:GetService("DataStoreService")
local ds1 = DataStore:GetDataStore("TrustCurrency")
local time = require(game.Workspace.getTime)
game.Players.PlayerAdded:connect(function(player)
local leader = Instance.new("Folder",player)
leader.Name = "StatStorage"
local Credits = Instance.new("IntValue",leader)
Credits.Name = "Credits"
Credits.Value = ds1:GetAsync(player.UserId) or 0
ds1:SetAsync(player.Id,Credits.Value)
print("Initial Load Complete")
Credits.Changed:connect(function()
print("Saving Data")
ds1:SetAsync(player.Id,Credits.Value)
print("Saved "..player.UserId.."'s Credit Balance of "..Credits.Value)
end)
end)
game.Players.PlayerRemoving:connect(function(player)
ds1:SetAsync(player.Id,player.StatStorage.Credits.Value)
print("Saved "..player.UserId.."'s Credit Balance of "..player.StatStorage.Credits.Value)
end)

1 comment
is it printing anything?