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.Text}
		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 is in a server script inside a button. Tthe button in this scenario acts as a frame, contsing multiple gui elements. there is a textlabel called price in this button just like the script. The label says owned or the price depenedding if the item has been purchased. This script saves the text of that label.

However, it doesn't work. When i hop into my place, the text button is refreshed and acts brand new as if no pruchase was ever made.

What is this priblem here?

2 comments

0

You Are using playeradded in a local script?

0

No, i only use playeradded in server scripts