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

Row == script.Parent.Parent.Name is true, but it's returning as false?

Asked by 4 years ago
Edited 4 years ago

Hi, I'm currently completely stumped because something that should be working fine is not working.

bindable.Event:Connect(function(tileToBeFired, Row)
    print("Bindable Fired.")
    if tileToBeFired == script.Parent.Name or Row == script.Parent.Parent.Name then
        print("Blue!")
    else
        print("This is not the tile you're looking for")
        print("This is "..(script.Parent.Name))
        print("The real tile is "..tileToBeFired)
        print("This is"..(script.Parent.Parent.Name))
        print(Row)
    end
end)

The idea is there are several tiles in a grid, and a bindable event fired from the main script simultaneously checks all of the tiles (or checks them quickly in succession, idk which) and if the tileToBeFired argument matches the name of the Tile the script is in, and the Row argument matches the name of the row the tile is located in, then it will fire the script of that tile and only that tile (i know it says 'or' in the script, that's just for testing purposes).

Ok, so the kicker is that if the tileToBeFired matches the name of the tile (script.Parent.Name), then the script correctly prints 'Blue!' to the output. However, whenever Row matches the row that the tile is located in, it returns as false and skips to the second part of the script, printing 'This is not the tile you're looking for' and all the rest. To prove that Row == script.Parent.Parent.Name is DEFINITELY TRUE, here's a sample of the output I get when the bindable event is fired.

Bindable Fired.
This is not the tile you're looking for
This is Tile2
The real tile is Tile3
This isRow7
Row7

As you can see, where it prints "This is "..(script.Parent.Parent.Name) is the exact same as where it prints (Row) (I'm speaking of the last two lines of the output). Because these are the same, the output should not have printed this at all, but instead printed 'Blue!'. It makes zero sense whatsoever to me, and I hope someone here is willing to think about this problem and help me with some ideas of what to try. I've tried asking this question a couple of times on the discord and was more or less ignored.

Oh yeah, if it helps here's the part of the main script which calls the bindable event in the first place

local function fireTile()
    for i,v in pairs(plrs) do
        for x,z in pairs(rows) do
            print(z)
            if v.RowString.Value == "ClickRow"..x then
                local Row = z
                for y,w in pairs(z:GetChildren()) do
                    if v.TileString.Value == "ClickTile00"..y then
                        local tileToBeFired = "Tile"..y
                        print("The tile to be fired is "..tileToBeFired)
                        bindable:Fire(tileToBeFired, Row)
                    elseif v.TileString.Value == "ClickTile0"..y then
                        local tileToBeFired = "Tile"..y
                        print("The tile to be fired is "..tileToBeFired)
                        bindable:Fire(tileToBeFired, Row)
                    end
                end
            end
        end
    end
end

This part should be fine. It basically just checks the RowString and TileString values of the player which changes according to what tile he/she has selected, and finds the corresponding tile in the gamespace, then fires the bindable event with the coordinates of that tile in the arguments (tileToBeFired and Row of course being the coordinates, corresponding to column and row).

I hope this makes sense. If more information, hierarchies or whatnot, is needed please let me know. I'm eager to continue scripting this game and this is a major non-sensical hurdle to me that I've been stuck on since yesterday.

Thanks for reading my essay XD

1 answer

Log in to vote
0
Answered by 4 years ago

I solved it. Apparently 'Row' was a userdata value, and so writing tostring(Row) at the top fixed the issue. I still don't know what a userdata value means, or why Row is a userdata value whenever tileToBeFired isn't, but hey it's working now.

Ad

Answer this question