PlayerDataStore = game:GetService("DataStoreService"):GetDataStore("SpeedCoilPurchase")
game.Players.PlayerAdded:Connect(function(plr)
	local id = "id-"..plr.userId
	local text = script.Parent.Price
	local GetSaved= PlayerDataStore:GetAsync(id)
	if GetSaved then 
	text.Text = GetSaved[1]
	else 
		local TexttoSave = {text.Value}
		PlayerDataStore:SetAsync(id, TexttoSave)
	end
end)


game.Players.PlayerRemoving:Connect(function(plr)
	local id = "id-"..plr.userId
	local Savetable = {script.Parent.Price.Text}
	PlayerDataStore:SetAsync(id, Savetable)
end)

This script is inside a button and it is in a normal script.

The button is in a shop gui. In a sense it acts like a frame because it contains textlabels and a picture. One text label (Called Price) is located under the button just like this script. It says the price, and once the item is purchased it says owned. The text of this label is how the button determines if it should let a click purchse the item. I made this script to save that text label.

And obviously, it doesn't work. Can you please fix the problme?

3 comments

0

Where is the button located? Is the gui surface, billboard or screen?

0

it is in starter gui. it is a screen gui

0

In line 9 it should be text.Text not text.Value. Also you don't have to save everything as table.