ScarPunk Posted August 17, 2018 Share Posted August 17, 2018 Hello every one ! So today i am making my third person code. In my code i need to compare the name of child i want and the name of each children(GetChildren()) but i have got this error. when i try to compare their name. CODE: function Script:GetChildByName(nameRequest) for i = 0 , self.entity:CountChildren() -1 do local ent = self.entity:GetChild(i) local entName = ent:GetKeyValue("name") if entName == nameRequest then System:Print(nameRequest + " has been found !") return ent end end return nil end Quote ART CODE SOUND Link to comment Share on other sites More sharing options...
macklebee Posted August 17, 2018 Share Posted August 17, 2018 The error tells you exactly the problem. You are trying to mathematically add something to a string in lua. In lua, concatenation is two periods not a plus sign. So your code should look like this: System:Print(nameRequest.." has been found!") https://www.lua.org/pil/3.4.html 1 Quote Win7 64bit / Intel i7-2600 CPU @ 3.9 GHz / 16 GB DDR3 / NVIDIA GeForce GTX 590 LE / 3DWS / BMX / Hexagon macklebee's channel Link to comment Share on other sites More sharing options...
ScarPunk Posted August 17, 2018 Author Share Posted August 17, 2018 4 minutes ago, macklebee said: The error tells you exactly the problem. You are trying to mathematically add something to a string in lua. In lua, concatenation is two periods not a plus sign. So your code should look like this: System:Print(nameRequest.." has been found !") https://www.lua.org/pil/3.4.html I was looking for the condition not for the print ?♂️ Thanks macklebee Quote ART CODE SOUND Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.