Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Help with DataStore?

Can someone tell me why this DataStore script won't work?

Main code:

local player = script.Parent.Parent
local gui = player.PlayerGui:WaitForChild("Game")
local frame = gui:WaitForChild("Cash")
local stats = player:WaitForChild("leaderstats")
local cash = stats:WaitForChild("Cash")

local key = "Cash"..player.userId
local service = game:GetService("DataStoreService"):GetDataStore("GameService")

cash.Changed:connect(function()
	frame.Cash.Text = "Awarding cash..."
	service:SetAsync(key,cash.Value)
	print("Updated cash to "..cash.Value)
	wait(4)
	frame.Title.Cash.Text = "$0"..cash.Value
	print("Updated cash to "..cash.Value)
end)

Leaderboard code:

game.Players.PlayerAdded:connect(function(player)
	local cash = Instance.new("IntValue",player)
	cash.Name = "Cash"
	while wait(5) do
		cash.Value = cash.Value + 5
	end	
end)

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.