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:

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)
0
is it printing anything? User#12356 0 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago
local player = game.Players.LocalPlayer
local display = script.Parent
local Credits = player.StatStorage.Credits
    display.Text = "You Have "..Credits.Value.." Credits Left."
    print("Displayed "..player.UserId.."'s Credit Balance of "..Credits.Value)

    Credits.Changed:connect(function()
        print("Value Changed")
        display.Text = "You Have "..Credits.Value.." Credits Left."
        print("Displayed "..player.UserId.."'s Credit Balance of "..Credits.Value)
    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