Leon Posted August 21, 2014 Share Posted August 21, 2014 Hi I'm following Ricky Weapon pickup tutorial https://www.youtube.com/watch?v=VWBGtJ7NQ4Y but after I attached the script to my weapon I have an error on line 30 that says Script.entered = false Script.exited = false Script.hadCollision = false Script.vModel = "" --path function Script:UpdatePhysics() if self.entered then if self.hadCollision == false then if self.exited == false then self.exited = true self.component:CallOutputs("TriggerExit") self.entered = false end end end self.hadCollision = false end function Script:Collision(entity, position, normal, speed) self.hadCollision = true self.component:CallOutputs("OnCollide") if self.entered == false then self.component:CallOutputs("TriggerEnter") if entity:GetKeyValue("type") == "player" then entity.script.weaponfile = self.vModel entity.script:Loadweapon() self.entity:Hide() end self.entered = true self.exited = false end end Quote Link to comment Share on other sites More sharing options...
Ma-Shell Posted August 21, 2014 Share Posted August 21, 2014 It should say LoadWeapon (with a big W) Quote Link to comment Share on other sites More sharing options...
Leon Posted August 21, 2014 Author Share Posted August 21, 2014 nope..I trie ..but doens work Quote Link to comment Share on other sites More sharing options...
DerRidda Posted August 21, 2014 Share Posted August 21, 2014 Did you follow the tutorial and actually create the LoadWeapon function? Make sure there are no typos anywhere. Quote Link to comment Share on other sites More sharing options...
Leon Posted August 21, 2014 Author Share Posted August 21, 2014 I'm following the tutoria land I'm doinog exactly what Rick done ..I controlled for typos errors but not found anything Quote Link to comment Share on other sites More sharing options...
Rick Posted August 21, 2014 Share Posted August 21, 2014 Can you show us your LoadWeapon() function, and what script do you have the LoadWeapon() function in. Want to make sure you have function Script:LoadWeapon() and not just function LoadWeapon(). Those 2 are at different scopes and could cause this error also. Quote Link to comment Share on other sites More sharing options...
Leon Posted August 21, 2014 Author Share Posted August 21, 2014 I dont have any loadweapon script-- In your tutorial I didnt see any loadweapon script if you are referring to fpsplayer script that contain the weaponscript...i didnt touch anything.. this... --Load the default weapon, if one is set if self.weaponfile~="" then local entity = Prefab:Load(self.weaponfile) if entity~=nil then if entity.script~=nil then entity.script.player = self self.weapon = entity.script self.weapon.entity:SetParent(self.camera) self.weapon.entity:SetRotation(0,0,0) if self.weapon.offset~=nil then self.weapon.entity:SetPosition(self.weapon.offset) else self.weapon.entity:SetPosition(0,0,0) end end end end Quote Link to comment Share on other sites More sharing options...
DerRidda Posted August 21, 2014 Share Posted August 21, 2014 I dont have any loadweapon script-- And that right there is your problem, you need to create a LoadWeapon function. You can't call what doesn't exist, ergo you get "nil" value errors. View the tutorial video again and you will see what is changed and where the LoadWeapon function is created. Quote Link to comment Share on other sites More sharing options...
Rick Posted August 21, 2014 Share Posted August 21, 2014 There is a point in the tutorial where I break out those lines of code that were in Script:Start() into their own function name LoadWeapon(). That's the part you must have missed. 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.