Player money values stores at ServerStorage.PlayerMoney folder with player names inside.
I tried both remote event and function. Both prints true values to output but changes not effects server side values.
This is local script
script.Parent.MouseButton1Click:Connect(function() local receiver = script.Parent.Parent._02receiverplayer.Text local amaount = script.Parent.Parent._03amaount.Text game.ReplicatedStorage.sendmoney:InvokeServer(receiver,amaount) end)
This is script inside ServerScriptService
game.ReplicatedStorage.sendmoney.OnServerInvoke = function(player, receiver, amaount) local receiverCheck = game.ServerStorage.PlayerMoney:FindFirstChild(receiver) if receiverCheck == nil then print("Receiver name invalid") elseif player.Name == receiver then print("You cant send money to yourself") else local totalplayermoney = game.ServerStorage.PlayerMoney[player.Name].Value print(player.Name.." "..totalplayermoney) --prints correct values local receiversmoney = game.ServerStorage.PlayerMoney[receiver].Value print(receiver.." "..receiversmoney) --prints correct values if totalplayermoney > amaount then totalplayermoney = totalplayermoney - amaount receiversmoney = receiversmoney + amaount print("transfer made") print(player.Name.." new sender money = "..totalplayermoney) --prints correct values print(receiver.." new receiver money = "..receiversmoney) --prints correct values end end end
Thanks for your help.
i removed if statements from server script and i didnt use variables and it works now. i dont know why.
new server script:
game:GetService("ServerScriptService") game.ReplicatedStorage.sendmoney.OnServerInvoke = function(player, receiver, amaount) game.ServerStorage.PlayerMoney[player.Name].Value = game.ServerStorage.PlayerMoney[player.Name].Value - amaount game.ServerStorage.PlayerMoney[receiver].Value = game.ServerStorage.PlayerMoney[receiver].Value + amaount end