Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

When I have 30$ and the car costs 50$ it says decimals, what is the problem? [Answerd]

It says so many numbers when I divide it by the price. But what term do I need (Multiplication, dividing, adding or subtracting) Or can someone help me.

--//Variables\\--
local player = game.Players.LocalPlayer
local gui = player:FindFirstChild("PlayerGui"):FindFirstChild("CarUI")
local button = gui:FindFirstChild("TextButton")
local money = player:FindFirstChild("leaderstats"):FindFirstChild("money")
local storage = game:GetService("ReplicatedStorage")
local model = storage:FindFirstChild("OffRoader")
local price = 50
--//Main Script\\--
button.MouseButton1Click:connect(function()
	if money.Value >= price then
		warn("Enough Money!")
		local clonecar = model:Clone()
		clonecar.Parent = workspace
		clonecar:MakeJoints()
	elseif money.Value <= 49 then
		warn("Not enough money!")
		button.Text = "Not Enough Money. You Have: $"..money.Value.." You need $"..money.Value /49 --// THIS IS THE PROBLEM
		button.BackgroundColor3 = Color3.new(255/255, 0/255, 0/255)
		wait(2)
		button.BackgroundColor3 = Color3.new(170/255, 255/255, 127/255)
		button.Text = "Spawn Off Roader"
	end
end)

1 answer

✓ Accepted answer

Just concatenate your price variable in :D

local player = game.Players.LocalPlayer
local gui = player:FindFirstChild("PlayerGui"):FindFirstChild("CarUI")
local button = gui:FindFirstChild("TextButton")
local money = player:FindFirstChild("leaderstats"):FindFirstChild("money")
local storage = game:GetService("ReplicatedStorage")
local model = storage:FindFirstChild("OffRoader")
local price = 50

button.MouseButton1Click:connect(function()
	if money.Value >= price then
		warn("Enough Money!")
		local clonecar = model:Clone()
		clonecar.Parent = workspace
		clonecar:MakeJoints()
	else
		warn("Not enough money!")
		local msg,need = "Not Enough Money. You Have: $"," You need $"
		button.Text = msg..money.Value..need..price
		button.BackgroundColor3 = Color3.new(255/255, 0/255, 0/255)
		wait(2)
		button.BackgroundColor3 = Color3.new(170/255, 255/255, 127/255)
		button.Text = "Spawn Off Roader"
	end
end)

2 comments

0

Thanks. I didn't know it was that easy, well I appriciate the help =)

0

No problem :D Happy Developing!

This discussion is preserved as it was. New answers, comments, and votes are closed.