I am currently working on a simulator game, and as I am about to finish the coding for alpha 1 I encountered an issue.
I am using 2 datastore API’s: datastore2 for my tables/money, and datastoreservice for an int value called “Robux”, which you will sell in game to earn money (which is also in game)
I am using 2 leaderstat folders: leaderstats_1 (for datastore2) and leaderstats_2 (for datastore service). Everything is working great, in fact I get no errors, and the values seem to be working. However, when I try changing the int value through my sell script (which is a server script, along with the datastoreservice script), it doesn’t change at all in game, and I get no syntax errors.
Code Example:
Local Script (used to send remote event to server script)
local player = game.Players.LocalPlayer
game.ReplicatedStorage.Remotes.OpenUI.OnClientEvent:Connect(function()
if player.leaderstats_2.Robux.Value > 0 then
script.Parent.BG.Title.Text = "Do you want to sell your "..player.leaderstats_2.Robux.Value.." R$?"
script.Parent.BG.Visible = true
script.Parent.BG.Position = UDim2.new(0.304, 0,1, 0)
script.Parent.BG:TweenPosition(UDim2.new(0.304, 0,0.128, 0), Enum.EasingDirection.Out, Enum.EasingStyle.Quad, .4, true)
end
end)
script.Parent.BG.Yes.MouseButton1Click:Connect(function()
script.Parent.BG.Title.Text = ""
script.Parent.BG.Visible = false
script.Parent.BG.Position = UDim2.new(0.304, 0,1, 0)
game.ReplicatedStorage.Remotes.ChangeRobux:FireServer()
game.ReplicatedStorage.Remotes.IncrementMoneyClient:FireServer(player.leaderstats_2.Robux.Value * 1.5)
end)
Server Script (sell script)
game.ReplicatedStorage.Remotes.ChangeRobux.OnServerEvent:Connect(function(player)
print("Recieved")
player.leaderstats_2:WaitForChild("Robux").Value = 0
end)
I have tried changing around code, changing values, etc. I just don’t know what the problem is.