Ugh, this is a real headache tbh. >.<
What I'm doing is I'm trying to get the predictions function, of the code below, to return a value for which to counter the player, but it doesn't, and only returns nil. I am not sure as to why this is happening, and I've looked it over, but I didn't notice anything wrong.
Although, from investigation, it seems the BlockedPath function is the cause, but I can't see any way how why, and how to fix it.
What counter-measures do you mean? Well, as an example, I have it set up, in a table, so that the compiler constructs a string, then the string compare to a prediction; say the compiler says '14,' and the win is '7,' but the code doesn't pick this up, and goes for a random space (value) instead.
This is the code I'm using:
local Predictions = { -- This is the predictions table; not very efficient, but hopefully it does the job {'12', '3'}, -- The first value is the warning value, and the second value is the number to prevent the match {'13', '2'}, {'14', '7'}, {'15', '9'}, {'17', '4'}, {'23', '1'}, {'25', '8'}, {'28', '5'}, {'35', '7'}, {'45', '6'}, {'46', '5'}, {'56', '4'}, {'59', '1'}, {'57', '3'}, {'78', '9'}, {'79', '8'}, {'89', '7'} } local Blocked = {} function BlockedPath(value) print('Check for blocked path') -- Prints for i, v in pairs(Blocked) do print(v, 'blocked') -- Prints if value == v then print('Path blocked') -- Prints return true end end print('No block') -- Doesn't print return false end function CompareValueToPredictions(value) print('Compare values') for i, v in pairs(Predictions) do print('Predictions:', v[1], v[2]) -- Prints if value == v[1] then print('Prediction') -- Prints if BlockedPath(v[1]) then print('Blocked') return end -- Prints table.insert(Blocked, v[1]) print(value, v[1], BlockedPath(v[1]), v[2]) -- Doesn't print return v[2] -- Doesn't return end end print('No comparison') -- Prints return nil -- Returns end function PreventPlayerFromWinning() print('Check for danger') table.sort(player1) -- Sort the spaces the player has ahold of local compile = '' -- To compile the names for i, v in pairs(player1) do compile = compile .. v -- Add to the compiler end for x = 1, 3 do -- If the first time fails, then try again another 2 lol local compareValuesToPredictions = CompareValueToPredictions(compile) -- Return the value print(compareValuesToPredictions, 'thing') -- nil thing if compareValuesToPredictions then -- Found match print('Prediction found') -- Doesn't print for i, v in pairs(script.Parent.Frame:GetChildren()) do if v == compareValuesToPredictions then print('Prevent') return v -- Return counter end end end end print('Failed') return nil -- Returns nil end
This is apart of the code that I'm submitting to the Snack Break #22; however, the code isn't working as I wanted it to, and I can't figure out why. ;-;