Okay so, I was working on a donating stats gui, i added the text boxes where you can enter the player's name that you want to donate to, your player name, and the amount you want to donate to the player, i also added a button that lets you donate below all the text boxes. And then when i finished working on the donate button, it just didn't show any errors and didn't even work
Donate button code:
function Donate() local amount = script.Parent.Parent.Amount.Text local plrName = script.Parent.Parent.Player.Text local plr = game.Players:FindFirstChild(plrName) local mplrName = script.Parent.Parent.MainPlayer.Text local mplr = game.Players:FindFirstChild(mplrName) if plr and mplr then local s1 = plr.leaderstats.Silks local s2 = mplr.leaderstats.Silks if s2.Value >= amount then s1.Value = s1.Value + amount s2.Value = s2.Value - amount end end end script.Parent.MouseButton1Click:Connect(Donate)
Explorer: https://pasteboard.co/K8eWQU1.png
Gui: http://pasteboard.co/K8eXD4i.png
actually, you can make a server script and a local script, first make a remote event, name it Donate then put it in replicated storage then do this for the local script:
script.Parent.MouseButton1Click:Connect(function() game.ReplicatedStorage.Donate:FireServer(script.Parent.Parent.Amount.Text, script.Parent.Parent.Player.Text, script.Parent.Parent.MainPlayer.Text) end)
and for the server script: this
game.ReplicatedStorage.Donate.OnServerEvent:Connect(function(plr, amount, plrtarget, plrmain) if game.Players:FindFirstChild(plrtarget) and game.Players:FindFirstChild(plrmain) then game.Players:FindFirstChild(plrtarget).leaderstats.Silk.Value = game.Players:FindFirstChild(plrtarget).leaderstats.Silk.Value + amount game.Players:FindFirstChild(plrmain).leaderstats.Silk.Value = game.Players:FindFirstChild(plrmain).leaderstats.Silk.Value - amount end end) script.Parent.MouseButton1Click:Connect(Donate)