Jump to content

weapon not appearing on startup


drarem
 Share

Recommended Posts

I have a strange error. I'm using this below. It happens with any gun. When I click a 'start' button to begin, the code is executed below, but the rifle doesn't appear and i can only get one shot off until I go to an object where the hand icon hovers over it, like a pick call. Then the gun appears and i can shoot. Does anyone have any ideas?

 

Thanks.

 

Mapfile contains the player prefab, pointing to the fpsplayer.lua script.

 

 

In the FPSPlayer.lua code:

 

if self.weaponfile~="" then

local prefab = Prefab:Load(self.weaponfile)

if prefab~=nil then

if prefab.script~=nil then

self:AddWeapon(prefab.script)

else

prefab:Release()

end--

end

end

Link to comment
Share on other sites

Changed it to this at the end of the Start() function in FPSPlayer.lua. When I point my crosshair at an object to pick up, the gun pops up. I wonder if this is in the picking?

 

if self.weaponfile~="" then

self.fgun = Prefab:Load(self.weaponfile)

if self.fgun~=nil then

if self.fgun.script~=nil then

self:AddWeapon(self.fgun.script)

System:Print("weapon should be added here, but it isn't")

else

self.fgun:Release()

end--

end

end

Link to comment
Share on other sites

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...