So im making kind of a shopping system, where if you have enough money, you click a part and you get another value (lets say gems). And after the purchase the price of gems scales up and costs more.
So i need to somehow save the new price in data stores so player cant constantly rejoin and buy gems for a cheap price when he is supposed to buy it for other price.
My guess is to save the price value inside the player with a datastore and then use that value for a price, but how do i detect a local player with a normal script? Or is there another method?
(Yes i know you cant use game.Players.LocalPlayer with a normal script)
I’m not a good scripter myself, but hopefully this does what you are trying to do
Yes, putting the value in the player leaderstats can make it only price it for them, make the gui locally show up if you are going to make it have an indicator of its price. You can use a local script that has these lines of code in it if you dont know how:
local plr = game.Players.LocalPlayer
script.Parent.ClickDetector.MouseClick:Connect(function() --script.Parent for if the script is in the part
plr.PlayerGui.GuiNameHere.Enabled = true --Change GuiNameHere to the name of the Gui
end)
Then, in the Gui, have a text button or image button that has a normal script with this code:
local Price = Instance.new("IntValue")
Price.Name = "ItemPrice" --Change if you want
script.Parent.MouseButton1Click:Connect(function(plr)
Price.Parent = plr.leaderstats
plr.leaderstats.Gems.Value = plr.leaderstats.Gems.Value - Price.Value --If gems is named something else, then change them here
Price.Value = Price.Value * 2 --I think this will scale the price. If it doesn't, let me know.
end)
To get it to save, do some datastore stuff. I suck at datastore, so I won’t include it, however it requires using the creator dashboard now.