Why isn't this script displaying the credits on the screen gui?
Asked by
8 years ago Edited 8 years ago
I want the Gui to show the Credit Count for the local player.
I have the Gui in Starter Gui with this script:
01 | local player = game.Players.LocalPlayer |
02 | local display = script.Parent.Text |
03 | local Credits = player.StatStorage.Credits |
04 | display = "You Have " ..Credits.Value.. " Credits Left." |
05 | print ( "Displayed " ..player.UserId.. "'s Credit Balance of " ..Credits.Value) |
07 | Credits.Changed:connect( function () |
08 | print ( "Value Changed" ) |
09 | display = "You Have " ..Credits.Value.. " Credits Left." |
10 | print ( "Displayed " ..player.UserId.. "'s Credit Balance of " ..Credits.Value) |
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:
01 | local DataStore = game:GetService( "DataStoreService" ) |
02 | local ds 1 = DataStore:GetDataStore( "TrustCurrency" ) |
03 | local time = require(game.Workspace.getTime) |
06 | game.Players.PlayerAdded:connect( function (player) |
07 | local leader = Instance.new( "Folder" ,player) |
08 | leader.Name = "StatStorage" |
09 | local Credits = Instance.new( "IntValue" ,leader) |
10 | Credits.Name = "Credits" |
11 | Credits.Value = ds 1 :GetAsync(player.UserId) or 0 |
12 | ds 1 :SetAsync(player.Id,Credits.Value) |
13 | print ( "Initial Load Complete" ) |
14 | Credits.Changed:connect( function () |
16 | ds 1 :SetAsync(player.Id,Credits.Value) |
17 | print ( "Saved " ..player.UserId.. "'s Credit Balance of " ..Credits.Value) |
21 | game.Players.PlayerRemoving:connect( function (player) |
22 | ds 1 :SetAsync(player.Id,player.StatStorage.Credits.Value) |
23 | print ( "Saved " ..player.UserId.. "'s Credit Balance of " ..player.StatStorage.Credits.Value) |