Jump to content

[SOLVED] hitElement got nil


Recommended Posts

Hi I have a error in my script, the debugscript send me "WARNING: Scripts\interact.lua:29: Bad argument 'getElementType' [Expected element at argument 1, got nil]"

this is in this par of my script:

function markerCol ( marker ) 
    if getElementType(hitElement) == "player" and (hitElement == localPlayer) then --LINE 29 (ERROR HERE) 
        guitank1() 
        guiSetVisible(gui,true) 
        showCursor(true) 
        outputConsole("réussi") 
    else 
        outputConsole("erreur") 
    end 
end 
addEventHandler( "onClientMarkerHit", marker, markerCol ) 

I can send you may all script (clientside):

-- spawn tank 1 
function guitank1() 
    gui = guiCreateWindow(0.25,0.25,0.5,0.13,"Contrôle du garage",true) 
    guiSetAlpha(gui,1) 
     
    button1 = guiCreateButton(0,70,900,20,"Fermer la fenêtre",false,gui) 
    guiSetAlpha(button1,1) 
    addEventHandler("onClientGUIClick", button1, closeguispawntank1) 
     
    button2 = guiCreateButton(0,20,900,20,"Ouvrir le garage",false,gui) 
    guiSetAlpha(button1,1) 
    addEventHandler("onClientGUIClick", button2, opendoor1) 
     
    button3 = guiCreateButton(0,45,900,20,"Fermer le garage",false,gui) 
    guiSetAlpha(button1,1) 
    addEventHandler("onClientGUIClick", button3, closedoor1) 
end 
  
function closeguispawntank1 () 
    guiSetVisible(gui,false) 
    showCursor(false) 
end 
  
marker = createMarker ( -692.20001, 959.29999, 11.2, "cylinder", 1, 255, 100, 100, 255 ) 
keypad = createObject ( 2886, -692.20001, 959.70001, 13 ) 
door = createObject ( 3037, -693.40002, 966.5, 13.4 ) 
  
function markerCol ( marker ) 
    if getElementType(hitElement) == "player" and (hitElement == localPlayer) then 
        guitank1() 
        guiSetVisible(gui,true) 
        showCursor(true) 
        outputConsole("réussi") 
    else 
        outputConsole("erreur") 
    end 
end 
addEventHandler( "onClientMarkerHit", marker, markerCol ) 
  
function opendoor1 () 
    moveObject (door, 60000, -693.40002, 966.5, 0) 
end 
  
function closedoor1 () 
    moveObject (door, 5000, -693.40002, 966.5, 13.4) 
end 

how can I fix it ?

PS: I can't open the GUI

Edited by Guest
Link to comment
    function markerCol ( hitElement ) 
        if getElementType(hitElement) == "player" and (hitElement == localPlayer) then --LINE 29 (ERROR HERE) 
            guitank1() 
            guiSetVisible(gui,true) 
            showCursor(true) 
            outputConsole("réussi") 
        else 
            outputConsole("erreur") 
        end 
    end 
    addEventHandler( "onClientMarkerHit", marker, markerCol ) 

Try

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...