Roblox Shop Gui Datastore

So Im making a gui where you can buy an item and then it takes 250 coins from your leaderstats. It also saves the item. I have it working untill it saves your item. Heres the code so far.

if game.Players.LocalPlayer.leaderstats:FindFirstChild(“Speed”) ~= nil then
script.Parent.Text = “Already Owned”
if game.Players.LocalPlayer.leaderstats.Coins.Value >= 250 then
local Instance1 =“TextLabel”)
Instance1.Parent = game.Players.LocalPlayer.leaderstats
Instance1.Name = “Speed”
game.Players.LocalPlayer.leaderstats.Coins.Value = game.Players.LocalPlayer.leaderstats.Coins.Value - 250
script.Parent.Text = “Bought”


I don’t have any clue how to save the “Speed” can someone help me. Thanks for reading.

Wait why are you instancing TextLabel and parenting it to the leaderstats? Try instancing a BoolValue
Make sure you have Datastore to save the value. Are you using a Local Script? or a Script?

Nevermind I figured out an alternative way to make it work. I ended up creating a value and setting it a specific number. Then all i had to do is save that number. if the player had that specific number they’d get a specific item.