generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Text to show how much more money u need to purchase item ?

Previous Thread :: Next Thread 
Bulvyte is not online. Bulvyte
Joined: 21 May 2014
Total Posts: 716
27 Jul 2016 07:08 AM
local items = script.Parent.Frame:GetChildren()
local notenough = script.Parent.Parent.notenough
local purchased = script.Parent.Parent.purchased

for i = 1, #items do
function buy()
Cash = script.Parent.Parent.Parent.Parent.leaderstats:FindFirstChild(items[i].Currency.Value)
local diff = Cash.Value - items[i].Currency.Value.Value
if Cash.Value >= items[i].Cost.Value then
Cash.Value = Cash.Value - items[i].Cost.Value
toolca = game.ReplicatedStorage:FindFirstChild(script.Parent.Folder.Value):FindFirstChild(items[i].ItemName.Value):Clone()
toolcb = game.ReplicatedStorage:FindFirstChild(script.Parent.Folder.Value):FindFirstChild(items[i].ItemName.Value):Clone()
toolca.Parent = script.Parent.Parent.Parent.Parent.Backpack
toolcb.Parent = script.Parent.Parent.Parent.Parent.StarterGear
print("Successfully bought!")
purchased.Visible = true
purchased.Text = "You have bought " ..items[i].ItemName.Value.. "!"
wait(1.5)
purchased.Visible = false

else print("Insufficient money!")

notenough.Visible = true
notenough.Text = "You don't have enough " ..items[i].Currency.Value.. "!"
--^^ here i kinda want to show how much more money u need to have to purchase this How can i do it ?
wait(1.5)
notenough.Visible = false
end
end
items[i].BuyButton.MouseButton1Click:connect(buy)
end



Report Abuse
ComedicGesture is not online. ComedicGesture
Joined: 20 May 2011
Total Posts: 912
27 Jul 2016 07:15 AM
Maybe I'm not understanding correctly but I think you just have to do this:
amountneeded = -difference
Think about it difference = your cash - price right???
so if price>cash then doing -difference would return a positive number which represents how much money you need to reach the price here i'll show you

-difference = yourcash - price
difference = -(yourcash - price)
difference = price - yourcash
difference + yourcash = price - so in essence yourcash needs difference more units to reach price




im not a jerk but homie u 5
Report Abuse
Bulvyte is not online. Bulvyte
Joined: 21 May 2014
Total Posts: 716
27 Jul 2016 07:28 AM
i still don't get it, what line do ineed to put to make it show it ?


Report Abuse
ComedicGesture is not online. ComedicGesture
Joined: 20 May 2011
Total Posts: 912
27 Jul 2016 07:30 AM
Write in the text line

text = "You don't have enough! You need $"..-diff.." more."


im not a jerk but homie u 5
Report Abuse
ComedicGesture is not online. ComedicGesture
Joined: 20 May 2011
Total Posts: 912
27 Jul 2016 07:31 AM
where it says notenough.Text = "You don't have enoguh!"


im not a jerk but homie u 5
Report Abuse
Disillusions is not online. Disillusions
Joined: 10 Jul 2011
Total Posts: 6365
27 Jul 2016 08:54 AM
notenough.Text = 'You need '..math.abs(diff)..' more '..items[i].Currency.Value..'!'

I guess?
Report Abuse
Bulvyte is not online. Bulvyte
Joined: 21 May 2014
Total Posts: 716
27 Jul 2016 01:47 PM
attempt to perform arithmetic on field 'Value' (a nil value)


Report Abuse
rocklego12 is not online. rocklego12
Joined: 09 Dec 2011
Total Posts: 289
27 Jul 2016 02:26 PM
try FindFirstChild() then^
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image