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

You need (money amount) left to buy this?

Asked by 9 years ago

Hi I was trying to make a script so if you try to buy something and you didn't have the right amount then it would say "You need ... more credits to buy this! ". Can you help? This is my guess.

    script.Parent.Text = plr.leaderstats.Credits.Value - 550

2 answers

Log in to vote
0
Answered by
Dr_Doge 100
9 years ago

Im not the best at coding but I'll give it a go...

script.Parent.Text = "You need "..550 - plr.leaderstats.Credits.Value.." more Credits to buy this!"

Try that... It should work...

Dont hate if it dose't... Im just trying to help o<o

Ad
Log in to vote
0
Answered by
Uroxus 350 Moderation Voter
9 years ago

First of, you need to check if the player has enough credits, If they do you set the textbox what ever you want (Eg: You have enough credits). If the check comes back and they do not have enough credits then the textbox is set to "You need more credits"

if plr.leaderstats.Credits.Value >= 550 then
    script.Parent.Text = "You have enough credits"
else
    local total = 550 - plr.leaderstats.Credits.Value 
    script.Parent.Text = "You need"..total" more credits to buy this!"
end 

Answer this question