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

Has anyone worked on a stock trading system script before?

Asked by 2 years ago

Hello! I'm working on a pre-developed stock trading system script. here is what I have so far:

local be = script.Parent.BE
local m = script.Parent.M
local octan = script.Parent.Octan

while true do
    c = game.Players:GetChildren()
    for i=1, #c do
        local frame = c[i].PlayerGui:findFirstChild("ScreenGui"):findFirstChild("StockMsg")
        frame.Visible = true
    end
    math.randomseed(tick())
    local newCostO = math.random(1,1000)-math.random(1,1000) 
    wait(1)
    local newCostM = math.random(2500,5000)-math.random(2500,5000) 
    wait(1)
    local newCostB = math.random(700,1500) - math.random(700,1500)

    be.Value = newCostB if newCostB > 1500 
        then newCostB = 1499

    m.Value = newCostM if newCostM > 5000 
        then newCostM = 4999
    octan.Value = newCostO if newCostO > 1000 then newCostO = 999

    wait(3)
    for i=1, #c do
        local frame = c[i].PlayerGui:findFirstChild("ScreenGui"):findFirstChild("StockMsg")
        frame.Visible = false
                end
            end
        end
    end

    wait(30)
end

I'm trying to change the local 'newcostX' to a random value without going beyond a cap. hence the 2 math.random's When running the script in game, it seems to freeze the script and doesnt go past where it shows the changed values. Does this read correctly? I believe I messed up the if/then statements or there is another script somewhere in my Workplace that isnt syncing properly with this one

2 answers

Log in to vote
0
Answered by 2 years ago

Sorry, answered my own questions here. I needed to change the math.random values to include negative number to positive number. I knew I needed to make the negative at least = to the positive so that one side wouldnt be over, leading to a greater chance of sticking to the max or sticking to the minimum. here is my updated script. So far its working out:

local be = script.Parent.BE
local m = script.Parent.M
local octan = script.Parent.Octan

while true do
    c = game.Players:GetChildren()
    for i=1, #c do
        local frame = c[i].PlayerGui:findFirstChild("ScreenGui"):findFirstChild("StockMsg")
        frame.Visible = true
    end
    math.randomseed(tick())
    local newCostO = octan.Value + math.random(-100,100)
    wait(1)
    local newCostB = be.value + math.random(-500,500)
    wait(1)
    local newCostM = m.Value + math.random(-500,500)

    be.Value = newCostB
    m.Value = newCostM
    octan.Value = newCostO

    wait(3)
    for i=1, #c do
        local frame = c[i].PlayerGui:findFirstChild("ScreenGui"):findFirstChild("StockMsg")
        frame.Visible = false
    end
    if octan.Value > 1000 then octan.Value = 1000 elseif octan.Value < 1 then octan.Value = 2
    end     
    if be.Value > 2500 then be.Value = 2500 elseif be.Value < 700 then be.Value = 700
    end
    if m.Value > 5000 then m.Value = 5000 elseif m.Value < 2500 then m.Value = 2500
    end
        wait(30)
end
Ad
Log in to vote
0
Answered by
enes223 327 Moderation Voter
2 years ago

hey you! have you ever heard of enes? if you are in trouble, better call enes!

Answer this question