Lua error -Bad argument #1 to remove - lua

When i try to remove the object from table using the following coding it returns a Bad argument error,
Code
table.remove(tablesArr[currentTableObj[currentTableCode].tableId]["STATUS"], currentTableObj[currentTableCode].tableId)
table.insert(tablesArr[currentTableObj[currentTableCode].tableId]["STATUS"], currentTableObj[currentTableCode].tableId,tostring(currentTableObj[currentTableCode].status+1))
Error
Bad argument #1 to 'remove' (table expected, got string)
I knew the syntax of removing is
table.remove(tablesArr,currentTableObj[currentTableCode].tableId);
But i want to remove the exact value in
tablesArr[currentTableObj[currentTableCode].tableId]["STATUS"]
How to remove the index value in 2d array in lua,Please help to solve.

If you want to remove value just set it to nil:
tablesArr[currentTableObj[currentTableCode].tableId]["STATUS"] = nil

Related

Glua error "attempt to call method 'GetPlayerVisible' (a nil value)"

I personally don't know how a built in function can be indexed as "nil" butthis error appeared and it haulted my nextbot's movement. heres my code that is causing this
if (!self:GetPlayerVisible() and chasing_timer > chasing_time) then
self.stopchasing = true
self.enraged = false
print("Chase stopped")
print("Increasing escaped chases count, new:", self.escapedchases)
self.escapedchases = self.escapedchases + 1
end
I tried replacing the "!" with "not" but it did nothing.
I don't know what self is but that table does not contain an element GetPlayerVisible. Hece you may not call it. Calling nil values doesn't make sense.
Ask yourself why you think this function exists. Typical reasons are typos, indexing the wrong table or not having implemented a function yet.
To avoid this error you basically have two options. Make sure you call something that exists, or don't call it.

roblox LUA Expected 'end' (to close 'than' at line 3), got '='

function teleportTo(placeCFrame)
local plyr = game.Players.LocalPlayer;
if plyr.Character then
return plyr.Character.HumanoidRootPart.CFrame = placeCFrame;
end
end
teleportTo(game:GetService("Workspace").game:GetService("Workspace").Zeppelin.FuelTank1.Tank.CFrame)
my code is here, idk much about coding thanks for helping
and if you told me how to make the player teleport to a moving object it would be so super
The error is telling you what is going on.
When the code was being interpreted line by line, it expected the next symbol to be end, but instead it got =.
That means that something about how you're using the equals sign is incorrect. So when we look at the line :
return plyr.Character.HumanoidRootPart.CFrame = placeCFrame
You cannot assign a value on the same line as a return command. return is used to pipe a value out of a function so it can be used where the function was called.
But I'm pretty sure that isn't what you intended, you just want to set a player's position. So to fix your issue, remove the return.
if plyr.Character then
plyr.Character.HumanoidRootPart.CFrame = placeCFrame
end
The reason you are getting an error is because = is usually defined as setting a value, and no code can be executed after a return or it will error
If you wanted to, you could add return after all the code is done executing

How do I fix this this prison script lua

TxAdmin Log
Server.lua file
I have try'd to change the nummbers but I think in the Database is something wrong
You're attempting to index result a nil value in line 170 of server.lua.
result is nil in this scope you you cannot do this result[0].
Either find out why result is nil and fix it or avoid indexing it if it is .
Your code suggests that you failed to assign the return value of your SQL query to a variable.
So try
local result = MySQL.Asynch.fetchAll("...
Still you should checker whether your query actually returned a result using a conditional statement or assertion.

Initialize two dimensional object array returns fatal error

I want to create a 2d array of teams. Therefore, I can reach with like Teams[0][i] or Teams[1][0]. First print returns correct value but second one returns fatal index out of range.
self.teams = [self.first_array , self.second_array]
print(self.teams[0][0].name)
print(self.teams[1][0].name)
Try doing:
self.teams = [self.first_array , self.first_array]
If this works, then there's something wrong with self.second_array specifically. Your syntax looks fine except we can't see the rest of the code, particularly where you're initializing self and its properties.

'AnyObject' Doesn't have a Member "contactUID" Even thought Intelitype Says it Does?

Another ameture hour Swift Programming Question.
I have been returning values for an object from an array of object "Any Object" "Results". The intellitype says I have an object in the array with a value "ContactUID" however when I try to use ContactUID I get an error saying 'AnyObject' Doesn't contain member 'contactUID'.
The Array called HBCContactList successfully returns, FirstName, LastName and all the other items listed on the screen in the code. However it Will not return the Value 'ContactUID'.
The Model has got the right item. However unlike all the others... ContactUID is a INT64 instead of a string... I have added some screenshots to assit with the process of explaining. Sorry it sounds complicated but I expect I am missing something stupid.
Autocomplete on iOS isn't always accurate, often it will just list all possible selectors / methods.
The root of your problem here is that even though you know HCCContactList holds only HBCDirectoryModel objects, the compiler doesn't as MOContext.executeFetchRequest(freq, error: nil) returns an Array which declares it contains AnyObject's ([AnyObject] / Array<AnyObject>). In order to refer to any of these objects as an HBCDirectoryModel you'll need to conduct a cast to this type.
The easiest way to do this is is to declare your HCCContactList as being an array of HBCDirectoryModel's instead of AnyObject's, and then casting the result of calling MOContext.executeFetchRequest() to this same type.
You can do this as follows
var HCCContactList: Array<HBCDirectoryModel> = []
HCCContactList = MOContext.executeFetchRequest(freq, error: nil) as Array<HBCDirectoryModel>
Or using the shorter syntax
var HCCContactList:[HBCDirectoryModel] = []
HCCContactList = MOContext.executeFetchRequest(freq, error: nil) as [HBCDirectoryModel]

Resources