0

So I'm trying to develop a fivem server without knowing much about coding. I get this error in a script I have and at row 66 I have this :

return { 'x': rects.x + (rects.width/2),'y': rects.y + (rects.height/2) };

Full :

// Get the abosolute position of a node

function getPosition(node) {

var rects = node.getClientRects()[0];

return { 'x': rects.x + (rects.width/2),'y': rects.y + (rects.height/2) }; }


Anyone who can help me out?

Note: This is a dublicated script (the script is officially named esx_crafting) which I wanted to seperate from the original one. It is used to craft items using what you have in your inventory but I wanted to make different list items depended on the x,y,z of each crafting menu. So that's the reason why I dublicated the scripts. If that's the problem, is there any other way to make this work?

Eva Hatz
  • 53
  • 1
  • 1
  • 5
  • `node.getClientRects()` doesn't return anything. Why is that, we can't say, as there's not enough information in the question. – Teemu Oct 22 '20 at 09:45
  • @Teemu - it does you know - but perhaps `node` is `display:none` - then it returns a DOMRectList of length 0 - so `node.getClientRects()[0]` is undefined - but `node.getClientRects()` is not undefined, otherwise the error would relate to `[0]` not `.x` – Jaromanda X Oct 22 '20 at 10:05

0 Answers0