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

Why isn't this script subtracting the value?

Asked by 10 years ago

The person inputs a number (the variable text) and converts the the number to a number value. It then subtracts the number from credits and adds the number (divided by 1000) to points. It then rounds it down.

The script isn't working, though. Any idea why? This is a global script in a button.

text = script.Parent.Parent.Input.Text
local player = script.Parent.Parent.Parent.Parent.Parent.Parent.Parent


text = (tonumber(text))


script.Parent.MouseButton1Click:connect(function()
    if player.Backpack.Player.Premium.Value == true and player.Backpack.Player.Credits.Value >= text then
        print("accepted")
        player.Backpack.Player.Credits.Value = player.Backpack.Player.Credits.Value - text
        player.Backpack.Player.Points.Value = player.Backpack.Player.Points.Value + (text / 1000)
        player.Backpack.Player.Points.Value = math.floor(player.Backpack.Player.Points.Value)
    else
        print("declined")
    end
end)

Answer this question