I have a currency in my game and I wanted players to donate it to each other, the script does work without filtering enabled, so then I tried remoteevents but I can't figure how to transfer the amount values and everything since the server doesnt see inside the playergui.
here is the code of a LocalScript inside StarterGui, which fires a remoteevent.
player = game.Players.LocalPlayer
currency = "Drachma"
recipient = ""
amount = 0
Frame = player.PlayerGui.DonationGUI.Frame
Frame.Submit.MouseButton1Down:Connect(function()
recipient = Frame.Player.Text
amount = tonumber(Frame.Amount.Text)
print("donate fired")
game.ReplicatedStorage.Donate:FireServer(player,currency,recipient,amount)
end)
here is the code of a server script inside ServerScriptService that recieves the RemoteEvent in ReplicatedStorage.
game.ReplicatedStorage.Donate.OnServerEvent:connect(function(player,currency,recipient,amount)
if player.leaderstatss[currency].Value >= amount then
-- Player has enough money to donate
game.Players[recipient].leaderstatss[currency].Value = game.Players[recipient].leaderstatss[currency].Value + amount
player.leaderstatss[currency].Value = player.leaderstatss[currency].Value - amount
else
print("not enough money")
end
end)

1 comment
There's no 10k robux but i'm sure this helped i'll accept your answer