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

This has an error because it cant load?

Whenever I try to run my module script, it comes up with this :

Requested module experienced an error while loading

this is my module script and my calling script

--- main script

local microbloxGUI = game.Workspace.Part.SurfaceGui.Display1
local mbxChangeVal = microbloxGUI.mbxChange.change
local mbxWorthVal = microbloxGUI.mbxWorth.worth

local stockChange = {}

function stockChange.microblox()
    local change = math.random(1,2)
    if change == 1 then
        if microbloxGUI.mbxWorth.worth < 5 then
            microbloxGUI.mbxChange.change = math.random(0.1, 0.5)
            local endVal = mbxChangeVal.Value + mbxWorthVal.Value
            print("Microblox has gone up by" .. endVal .. " !")
        elseif microbloxGUI.mbxWorth.worth > 5 then
            microbloxGUI.mbxChange.change = math.random(0.35, 0.75)
            local endVal = mbxChangeVal.Value + mbxWorthVal.Value
            print("Microblox has gone down by" .. endVal .. " !")
        end
    end
end

return stockChange
ckChange


---- calling script 

local stockChangeCalculator = require(game.Lighting.StockChangeMain)


while wait(20) do
	stockChangeCalculator.microblox()
end



1 comment

0

What's with this 'ckChange' at line 25?

2 answers

Try this:

All I did was remove the "ckChange" at line 25. Should work now.

--- main script

local microbloxGUI = game.Workspace.Part.SurfaceGui.Display1
local mbxChangeVal = microbloxGUI.mbxChange.change
local mbxWorthVal = microbloxGUI.mbxWorth.worth

local stockChange = {}

function stockChange.microblox()
    local change = math.random(1,2)
    if change == 1 then
        if microbloxGUI.mbxWorth.worth < 5 then
            microbloxGUI.mbxChange.change = math.random(0.1, 0.5)
            local endVal = mbxChangeVal.Value + mbxWorthVal.Value
            print("Microblox has gone up by" .. endVal .. " !")
        elseif microbloxGUI.mbxWorth.worth > 5 then
            microbloxGUI.mbxChange.change = math.random(0.35, 0.75)
            local endVal = mbxChangeVal.Value + mbxWorthVal.Value
            print("Microblox has gone down by" .. endVal .. " !")
        end
    end
end

return stockChange


1 comment

0

Im sorry, that was a mistake on my part, i copy and pasted it wrong

Your variables are causing the problem. Make sure that game.Workspace.Part has a SurfaceGui, or maybe there are multiple objects named Part in the workspace and the script is selecting the wrong one.

It could also be that there is a random ckChange after the return, but i'll assume it's a typo.

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