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

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

Asked by
RootEntry 111
7 years ago
Edited 7 years ago

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

Log in to vote
0
Answered by
Goulstem 8144 Badge of Merit Moderation Voter Administrator Community Moderator
7 years ago
Edited 7 years ago

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)
0
Thanks. I didn't know it was that easy, well I appriciate the help =) RootEntry 111 — 7y
0
No problem :D Happy Developing! Goulstem 8144 — 7y
Ad

Answer this question