I made a script for the shopping gui. And I created leaderstats inside the datastore. But when i get data from server script to local script or when i buy something from store, i don’t get data. So when I buy something, my money is goes off, when I rejoin the game, my money is still the same as at the beginning of the game. Because my shopping gui local script and my datastore in serverscript. Is there any possible way to get data in every script types? Thanks in advance.
You need to use RemoteEvents in order for the money changes to replicate to the server. If you could send your scripts, it would help.
really hard to help since there is no snippet of script, it would make the job easier to detect what’s going on
you said: But when i get data from server script to local script or when i buy something from store, i don’t get data.
when creating some sort of SHOP, make sure to send to the server what you wish to buy, you must create some sort of variable, send to the server, depending on what you sent
[example]
this is a remote event:
local BuyItem = game:GetService("ReplicatedStorage") -- any location you can choose
yourGuiHere:Connect(function()
-- your stuff here
BuyItem:FireServer(player, Selected_Item]
end)
Selected Item is some [StringValue] [Boolvalue] can be anything, as long you know what you are trying to do
server side is
local BuyItem = game:GetService("ReplicatedStorage") -- don't forget to put this on the server side
BuyItem.OnServerEvent:Connect(function(player, Selected_Item)
you can
print(Selected_Item)
--here, the server will check the name of the item
-- datastore stuff, since you dind't posted any snippet of code to help
end)
1 Like
Oh i understand thanks. Thir-ty Ch-ars