# I am getting this (Expected element at arguement 1 got nil) help me

## Recommended Posts

```-- 1352 , -1769 , 14
function storerob()
--if x <= 1356 and x >= 1348 then
--if y <= -1773 and y >= -1765 then
--outputChatBox("you are here   ", player, 0, 0, 0)
function announce()
---------------------------------------------------------------------------------------------
outputChatBox("   ", root, 0, 0, 0)
outputChatBox("-----------------------------------------------------", root, 255, 0, 0)
outputChatBox("[ALERT] Someone has breaked the Locker in Store !!", root, 255, 0, 0)
outputChatBox("-----------------------------------------------------", root, 255, 0, 0)
outputChatBox("   ", root, 0, 0, 0)
---------------------------------------------------------------------------------------------
end
function loope()
outputChatBox("Robbing the money ...", player, 0, 255, 0)
end
---------------------------------------------------------------------------------------------
function money2()

money = math.random(200000, 400000)
givePlayerMoney( player, money )
outputChatBox("   ", player, 0, 0, 0)
outputChatBox("------------------------------------------------------", player, 0, 255, 0)
outputChatBox("You got \$"..money.." by robbing a Store !! ", player, 0, 255, 0)
outputChatBox("------------------------------------------------------", player, 0, 255, 0)
outputChatBox("   ", player, 0, 0, 0)
givePlayerMoney( player, money )

end
---------------------------------------------------------------------------------------------
announce()
loope()
money2()

--else
--outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
--end
--else
--outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
--end

end

Most likely  loope() and money2() player argument not passed through the function

You will need to pass the player like this

loope( player )

money2( player )

edit: moved the topic to scripting section for best results!

Thank you so much !

but I got the same error again

May I see the updated script?

Correct form:

```function storerob(player commandName) -- define player in function!
-- no need to create 50+ functions, everything can be done in the same function.
local money = math.random(200000, 400000);
outputChatBox("   ", root);
outputChatBox("-----------------------------------------------------", root, 255, 0, 0);
outputChatBox("[ALERT] Someone has breaked the Locker in Store !!", root, 255, 0, 0);
outputChatBox("-----------------------------------------------------", root, 255, 0, 0);
outputChatBox("   ", root);
outputChatBox("Robbing the money ...", player, 0, 255, 0);
outputChatBox("   ", player);
outputChatBox("------------------------------------------------------", player, 0, 255, 0);
outputChatBox("You got \$"..money.." by robbing a Store !! ", player, 0, 255, 0);
outputChatBox("------------------------------------------------------", player, 0, 255, 0);
outputChatBox("   ", player);
givePlayerMoney(player, money);
end

I need to make it a 5 min delay with settimer and loop the "Robbing the Money"

here is the script which i modified

-- 1352 , -1769 , 14
function storerob()
--if x <= 1356 and x >= 1348 then
--if y <= -1773 and y >= -1765 then
--outputChatBox("you are here   ", player, 0, 0, 0)
---------------------------------------------------------------------------------------------
outputChatBox("   ", root, 000)
outputChatBox("-----------------------------------------------------", root, 25500)
outputChatBox("[ALERT] Someone has breaked the Locker in Store !!", root, 25500)
outputChatBox("-----------------------------------------------------", root, 25500)
outputChatBox("   ", root, 000)
---------------------------------------------------------------------------------------------

function loope(player)

outputChatBox("Robbing the money ...", player, 02550)

end

setTimer(loope, 100029)

---------------------------------------------------------------------------------------------
function money2(player)
money = math.random(200000400000)
givePlayerMoney( player, money )
outputChatBox("   ", player, 000)
outputChatBox("------------------------------------------------------", player, 02550)
outputChatBox("You got \$"..money.." by robbing a Store !! ", player, 02550)
outputChatBox("------------------------------------------------------", player, 02550)
outputChatBox("   ", player, 000)
givePlayerMoney( player, money )

end
---------------------------------------------------------------------------------------------

setTimer( money2, 300001 )

--else
--outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
--end
--else
--outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
--end

end

I need to make it a 5 min delay with settimer and loop the "Robbing the Money"

here is the script which i modified

-- 1352 , -1769 , 14
function storerob()
--if x <= 1356 and x >= 1348 then
--if y <= -1773 and y >= -1765 then
--outputChatBox("you are here   ", player, 0, 0, 0)
---------------------------------------------------------------------------------------------
outputChatBox("   ", root, 000)
outputChatBox("-----------------------------------------------------", root, 25500)
outputChatBox("[ALERT] Someone has breaked the Locker in Store !!", root, 25500)
outputChatBox("-----------------------------------------------------", root, 25500)
outputChatBox("   ", root, 000)
---------------------------------------------------------------------------------------------

function loope(player)

outputChatBox("Robbing the money ...", player, 02550)

end

setTimer(loope, 100029)

---------------------------------------------------------------------------------------------
function money2(player)
money = math.random(200000400000)
givePlayerMoney( player, money )
outputChatBox("   ", player, 000)
outputChatBox("------------------------------------------------------", player, 02550)
outputChatBox("You got \$"..money.." by robbing a Store !! ", player, 02550)
outputChatBox("------------------------------------------------------", player, 02550)
outputChatBox("   ", player, 000)
givePlayerMoney( player, money )

end
---------------------------------------------------------------------------------------------

setTimer( money2, 300001 )

--else
--outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
--end
--else
--outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
--end

end
Posted (edited)

Maybe you didn't take a close look on what @Tekken posted. You are missing the argument "player" in the function storerob().
Also to make those timers work you will need to pass them the player element as well - as an optional argument (check setTimer documentation).

It should be something like this:

```-- 1352 , -1769 , 14
function storerob(player)
--if x <= 1356 and x >= 1348 then
--if y <= -1773 and y >= -1765 then
--outputChatBox("you are here   ", player, 0, 0, 0)
---------------------------------------------------------------------------------------------
outputChatBox("   ", root, 0, 0, 0)
outputChatBox("-----------------------------------------------------", root, 255, 0, 0)
outputChatBox("[ALERT] Someone has breaked the Locker in Store !!", root, 255, 0, 0)
outputChatBox("-----------------------------------------------------", root, 255, 0, 0)
outputChatBox("   ", root, 0, 0, 0)
---------------------------------------------------------------------------------------------

function loope(player)
outputChatBox("Robbing the money ...", player, 0, 255, 0)
end

setTimer(loope, 1000, 29, player)

---------------------------------------------------------------------------------------------
function money2(player)
money = math.random(200000, 400000)
givePlayerMoney( player, money )
outputChatBox("   ", player, 0, 0, 0)
outputChatBox("------------------------------------------------------", player, 0, 255, 0)
outputChatBox("You got \$"..money.." by robbing a Store !! ", player, 0, 255, 0)
outputChatBox("------------------------------------------------------", player, 0, 255, 0)
outputChatBox("   ", player, 0, 0, 0)
givePlayerMoney( player, money )
end
---------------------------------------------------------------------------------------------

setTimer(money2, 30000, 1, player)

--else
--outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
--end
--else
--outputChatBox("You are not Near the Locker !!", player, 255, 0, 0)
--end

end

*PS: Please, use the "code" tool in the text editor when you paste Lua code.

Edited by SpecT

it is working now ! thank you guys !

## Create an account

Register a new account