Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to make a cash donation GUI that can give in-game currency to other players?

Asked by
soutpansa 120
7 years ago

In a project I'm working on, I have a currency that is obtained through quests, killing things, etc. It is called Knux, and it is NOT a leaderstat. It is a data value that is displayed in-game via a gui. I have scripts and buttons set up to open a gui to donate the currency already, but I'm not quite sure how to be able to input a user's name and currency value to donate it to an existing player. Can anyone help with this?

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

What you can do is make two TextBoxes. TextBoxes are places where the player can type and edit what is inside it. One can be for the user they want to donate to, and the other can be the amount of money they wish to donate.

An example in a script would be this (Assuming the script is in the button you click, you can edit it to be anywhere though)

script.Parent.MouseButton1Click:connect(function()
plr=game.Players.LocalPlayer -- This is assuming it's in a local script, if it isn't simply change it around to find the player.
name=script.Parent.Parent.TextBoxName
donateamt=tonumber(script.Parent.TextBoxName.Text) --Because it's text, you have to make this string a number so you can do math with it
cashtotal=1+1 --Obviously this is not 1+1, but just put something here to reference to wherever you can find the player's current total money

if cashtotal>=donateamt and name~=plr.Name then --This checks to see if they have enough to donate in the first place and they aren't donating to themselves
--This is where I can't help you much, because I don't know where to find the player to be donated's current cash value. Basically you can take the value of donateamt and add it to the donated player's 
end
end

I'm not sure if that's all you want to know, but I can supply more help if needed.

Ad

Answer this question