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

Why is this addition variable not calculating correctly?

Asked by
RoboFrog 400 Moderation Voter
9 years ago

As of now, I'm having an issue getting a variable to add together properly. This is part of a pickaxe script (as will be evident) and isn't the full script. It's missing the mining portion, but I don't think that's needed. Here's the current snippet:

local light = game.Lighting.globaltyc
local ipath = game.Workspace.Tycoon.Tycoon.InvInt
local gui3true = game.Workspace.Tycoon.Tycoon.gui3true.Value
local invint = game.Workspace.Tycoon.Tycoon.InvInt -- Integer container (working as a model)
local invlim = game.Workspace.Tycoon.Tycoon.InvLimit -- Integer value

local hit = (tostring(game.Players:findFirstChild("humanoid")))
local debounce = true
local on = script.Parent.Name
local mouse = game.Players.LocalPlayer:GetMouse()
local minetotal = invint.Stone.Value + invint.Copper.Value + invint.Tin.Value + invint.Silver.Value + invint.Gold.Value + invint.Platinum.Value + invint.Sapphire.Value + invint.Emerald.Value + invint.Ruby.Value + invint.Diamond.Value + invint.StoneB.Value + invint.CopperB.Value + invint.TinB.Value + invint.SilverB.Value + invint.GoldB.Value + invint.PlatinumB.Value + invint.SapphireC.Value + invint.EmeraldC.Value + invint.RubyC.Value + invint.DiamondC.Value


function onActivated(mouse)

    if debounce == false then return end
    debounce = false

    if not mouse then return end

    local targ = mouse.Target

    slash()

    if targ ~= nil then

        if targ.Parent ~= nil then

            if (targ.Position - script.Parent.Parent.Head.Position).magnitude < picksize then

                local human = targ.Parent:findFirstChild("Humanoid")

                if human ~= nil then
                    print("Found human")

                    human:TakeDamage(10+math.random(30))

                else

                    if minetotal > invlim.Value then
                    print("Inventory limit reached!") -- Never displays, even when full.
                    OreNote() return -- Displays a GUI
                    else    
                    print("Inventory has "..(invlim.Value - minetotal).." space!") -- Always displays 10.
                    print("You currently have "..minetotal.." items!") -- Always displays 0.
                    print("You currently have "..invint.Stone.Value.." stone!")  -- This, for some reason, works. It displays the correct amount.

-- Even if the third print is >0, it still displays 0.
  • Please note the comments (--). Those will explain the outputs and any concerns, or more clarification on what something is.

If you need any more information, please let me know. I don't see any reason why this isn't adding correctly. Thank you for reading!

Answer this question