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

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:

01local player = game.Players.LocalPlayer
02local display = script.Parent.Text
03local Credits = player.StatStorage.Credits
04    display = "You Have "..Credits.Value.." Credits Left."
05    print("Displayed "..player.UserId.."'s Credit Balance of "..Credits.Value)
06 
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)
11    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:

01local DataStore = game:GetService("DataStoreService")
02local ds1 = DataStore:GetDataStore("TrustCurrency")
03local time = require(game.Workspace.getTime)
04 
05 
06game.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 = ds1:GetAsync(player.UserId) or 0
12    ds1:SetAsync(player.Id,Credits.Value)
13    print("Initial Load Complete")
14    Credits.Changed:connect(function()
15        print("Saving Data")
View all 24 lines...
0
is it printing anything? User#12356 0 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
01local player = game.Players.LocalPlayer
02local display = script.Parent
03local Credits = player.StatStorage.Credits
04    display.Text = "You Have "..Credits.Value.." Credits Left."
05    print("Displayed "..player.UserId.."'s Credit Balance of "..Credits.Value)
06 
07    Credits.Changed:connect(function()
08        print("Value Changed")
09        display.Text = "You Have "..Credits.Value.." Credits Left."
10        print("Displayed "..player.UserId.."'s Credit Balance of "..Credits.Value)
11    end)

it's picky about where .text is from line 2, you had script.Parent.Text

it need to go to line 4 "display.Text = "You have...."

0
I figured this out...I had two lines repeated..Thanks! snoppyploptart 59 — 8y
0
no problem. i tried that before too. i dont know why it's so picky xD User#12356 0 — 8y
Ad

Answer this question