Hello all.
I was hoping someone could help me find a solution for my gifting system.
Output:
Local Script:
local Player = game.Players.LocalPlayer
local StudsValue = Player:FindFirstChild("leaderstats").Studs
local GiftFrame = script.Parent
local AmountBox = GiftFrame.AmountBox
local SendButton = GiftFrame.Send
local UsernameBox = GiftFrame.UsernameBox
SendButton.MouseButton1Down:Connect(function()
local Amount = tonumber(AmountBox.Text)
local User = UsernameBox.Text
if StudsValue.Value >= Amount and game.Players:FindFirstChild(User) then
local newamount = Amount
game.ReplicatedStorage.GiftingStuds:InvokeServer(Player, User, newamount)
--StudsBalue.Value -= Amount
--game.Players:FindFirstChild(User):FindFirstChild("leaderstats").Studs.Value += Amount
SendButton.Text = "Sent"
task.wait(1)
SendButton.Text = "Send"
else
SendButton.Text = "Something went wrong."
task.wait(1.5)
SendButton.Text = "Send"
end
end)
game:GetService("ScriptContext").Error:Connect(function(msg, _, script)
SendButton.Text = "Something went wrong."
task.wait(1)
SendButton.Text = "Send"
end)
Server Script:
game.ReplicatedStorage.GiftingStuds.OnServerInvoke = function(Gifter, Reciever, Amount)
Gifter:FindFirstChild("leaderstats").Studs.Value -= Amount
game.Players:FindFirstChild(Reciever):FindFirstChild("leaderstats").Studs.Value += Amount
end
There is a RemoteFunction in Replicated Storage and the currrency is ‘studs’.
Any help is appreciated.
Thanks!
@Tomroblox54321