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

Object Parser Error?

Asked by 10 years ago
function objectParser(str)
    local obj = game.Players.LocalPlayer.PlayerGui
    local s, e = str:find'.-%.'
    if not s then
        return game[str:match'.+']
    else
        local object = str:match'.-%.'
        obj = game[object:sub(1, #object - 1)]
        print(object, str, e)
        str = str:sub(e)
        print(str)
        local leftovers = str
        for word in str:gmatch'%..-%.' do
            local s, e = str:find(word)
            leftovers = str:sub(e + 1)
            print(word)
            obj = obj[word:sub(2, #word-1)] -- Line 17
            print(leftovers)
        end
        return obj[leftovers]
    end
end
-------------- Skipping Lines
m.KeyDown:connect(function(key)
local  LK=Lane.Value
print(LK)
if Pos.Value~="LeftLane" then return end
if key~="q" then return end 
if key=="q" and objectParser(LK).Position.Y.Scale >=0.202 then  -- Line 130

    print("Bad")
elseif key=="q" and objectParser(LK).Position.Y.Scale >= 0 and objectParser(LK).Position.Y.Scale <= 0.161 then 

     print("Cool")
elseif key=="q" and objectParser(LK).Position.Y.Scale >= 0 and objectParser(LK).Position.Y.Scale<= 0.059 then

    print("Perfect")
    objectParser(LK):Remove()
if objectParser(LK)==nil then return


end  end end)

Lane is a StringValue and I'm using an ObjectParser to make it functional. I'm doing this so that the script can figure out which note is prioritized in a Dance Dance Revolution GUI game. Lane's value is a full name of an object. For example Lane.Value=Players.Player.PlayerGui.Game.Board.Lanes.LeftLane.16

Don't Know what's wrong. Please help.

18:47:45.059 - Game is not a valid member of Player 18:47:45.061 - Script 'Players.Player.PlayerGui.Game.Script', Line 17 - global objectParser 18:47:45.063 - Script 'Players.Player.PlayerGui.Game.Script', Line 130 18:47:45.063 - Stack End

1
You should probably just use an ObjectValue or some simpler method to find objects (special generated names + workspace:FindFirstChild(unique, true) ?) If you just need a working solution, here is another thread that asks this question: https://scriptinghelpers.org/questions/7192/how-would-i-convert-a-string-to-an-object-reference#9407 BlueTaslem 18071 — 10y
0
Thank you so much. SamDomino 65 — 10y

Answer this question