Jump to content

very simple script not working


Recommended Posts

function test() 
local player = getPlayerName (source) 
    outputChatBox("Say hello to " .. player .. ":D") 
end 
addEventHandler("onPlayerJoin", test) 

WARNING: test\script.lua:5: Bad argument @ 'addEventHandler' [Expected element at argument 2, got function]

I doubt that i have to explain what i'm doing because it's obvious imo.

Link to comment
  
function test () 
outputChatBox ("Say Hello to " ..getPlayerName (source).." : D", getRootElement()) -- getRootElement() will send message to everyone  
end 
addEventHandler ("onPlayerJoin", getRootElement(), test)  
-- syntax for event Handler is (EventName, AttachTo, functionName ) 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...