noblebrad121 Posted August 21, 2016 Share Posted August 21, 2016 Hello i am trying to create a spawner just a simple one and it seems to have a small error i dont understand. Any help would be greatly appreciated. here is my code Script.spawnObject = "" --entity "spawn object" Script.spawnTime= 1.0 --float "Spawn time" self.timer = 0 function Script:UpdateWorld() self.timer = self.timer + (Time:GetSpeed()/100) if(self.timer > self.spawnTime) then local newObject = self.spawnObject:Instance() newObject:SetPosition(self.entity:GetPosition {)} self.timer = 0 end end and the error i get says script error unexpected symbol near ')' line 9 that is the only error that it has came up with. thank you for any help Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 21, 2016 Share Posted August 21, 2016 newObject:SetPosition(self.entity:GetPosition {)} should be a '(' not a '{' 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...
Crazycarpet Posted August 21, 2016 Share Posted August 21, 2016 Well forst on line 3 is self not nil? But your errors talking about line 9 where you accidentally used curly brackets. newObject:SetPosition(self.entity:GetPosition()) 1 Quote Link to comment Share on other sites More sharing options...
noblebrad121 Posted August 21, 2016 Author Share Posted August 21, 2016 thank you Quote Link to comment Share on other sites More sharing options...
noblebrad121 Posted August 21, 2016 Author Share Posted August 21, 2016 well that fixed the line 9 but now the line 3 error came up it says script error attempt to index global 'script' (a nil value) line 3 i changed the script to this Script.spawnObject = "" --entity "spawn object" Script.spawnTime= 1.0 --float "Spawn time" script.timer = nil function Script:UpdateWorld() self.timer = self.timer + (Time:GetSpeed()/100) if(self.timer > self.spawnTime) then local newObject = self.spawnObject:Instance() newObject:SetPosition(self.entity:GetPosition ()) script.timer = 0 end end and it still did it after i changed the script. btw i am really new to programming and stuff i dont really have any experience Quote Link to comment Share on other sites More sharing options...
noblebrad121 Posted August 21, 2016 Author Share Posted August 21, 2016 I figured it out forgot to put cap S instead of s Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 21, 2016 Share Posted August 21, 2016 Also, Script.timer should initially be set to 0 not nil or it will fail to add in the Script:UpdateWorld() function. Also, in the Script:UpdateWorld() function, using 'self.timer = 0' is the same as using 'Script.timer = 0' due to self = Script inside that function. Suggest you go through the lua Tutorials located at the bottom of the tutorial page: http://www.leadwerks.com/werkspace/page/tutorials/ 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...
noblebrad121 Posted August 21, 2016 Author Share Posted August 21, 2016 well its not spawning objects and for some odd reason the script:UpdateWorld() is not blue like it should be. but function is blue. Script.spawnObject = "" --entity "spawn object" Script.spawnTime= 1.0 --float "Spawn time" Script.timer = 0 function Script:UpdateWorld() self.timer = self.timer + (Time:GetSpeed()/100) if(self.timer > self.spawnTime) then local newObject = self.spawnObject:Instance() newObject:SetPosition(self.entity:GetPosition ()) self.timer = 0 end end thank you for mentioning that its good to know. Quote Link to comment Share on other sites More sharing options...
macklebee Posted August 21, 2016 Share Posted August 21, 2016 It works for me just fine. Did you drag an entity from the Scene panel into the Script's property panel? And the Script:UpdateWorld() is not blue. Script.spawnObject = "" --entity "spawn object" Script.spawnTime= 1.0 --float "Spawn time" Script.timer = 0 function Script:UpdateWorld() self.timer = self.timer + (Time:GetSpeed()/100) if(self.timer > self.spawnTime) then local newObject = self.spawnObject:Instance() newObject:SetPosition(self.entity:GetPosition()) self.timer = 0 end end function Script:PostRender(context) context:SetBlendMode(1) context:DrawText("Timer: "..self.timer,2,142) context:SetBlendMode(0) end 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...
noblebrad121 Posted August 21, 2016 Author Share Posted August 21, 2016 yeah ive dragged it from the scene tab and still nothing. ive tired a few object and its still the same result Quote Link to comment Share on other sites More sharing options...
noblebrad121 Posted August 21, 2016 Author Share Posted August 21, 2016 now its working im not sure i changed the mat on the object and now it works thank you so much Quote Link to comment Share on other sites More sharing options...
Thirsty Panther Posted August 21, 2016 Share Posted August 21, 2016 Are you using Aggrors scripts? If so you can avoid these unpleasant typos but downloading his scripts here. http://www.aggrortutorials.com/index.php/downloads/viewcategory/4-project-saturn Quote 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.