fhl42 Posted November 2, 2017 Share Posted November 2, 2017 when i use self.entity:Release() the exe crashes when playing and use the health when i keep the player in idle anim its not crashing but when i move or rotate player with weapon the exe crashes, can someone say how to use it i use it in Health pickup when enemy dead it pops out of the enemy a health box, tutorial was on youtube i am new to lua i am a beginner here is the healthpickup script Script.health = 15.0 --float "Health" Script.useOnce = true --bool "Use once" function Script:Start() if self.health < 0 then error("Health can't be a negative value.") end end function Script:Use(player) if player.script.health < player.script.maxHealth then player.script:ReceiveHealth(self.health) if self.useOnce then self.entity:Release() end end end Quote Link to comment Share on other sites More sharing options...
Rozen Software Posted November 2, 2017 Share Posted November 2, 2017 Try using: self.entity:Hide() instead of self.entity:Release() I suppose it's not a proper way to destroy an entity from a working script attached to it. If you would like to release it anyway try to do it somewhere else (in an asset manager for example that you could write yourself). Quote Link to comment Share on other sites More sharing options...
fhl42 Posted November 2, 2017 Author Share Posted November 2, 2017 self.entity:Hide() is working beautiful i am happy with that Thanks. Quote Link to comment Share on other sites More sharing options...
Angelwolf Posted November 3, 2017 Share Posted November 3, 2017 You could also try releasing after hiding either immediately or after a few seconds. I've had some funky issues in the past when trying to release an entity but it's still performing actions, so my solution was to hide it then release after a few seconds - worked well in my projects. Just remember, you're hiding that item, not destroying it. Not much of an issue on a small scale but on a larger project you'll probably want to scrap the band-aid solution for a proper one. 1 Quote My Games: Nightmare Prism:::WolfTale:::Dungeon Creeper:::Despair of Ordinary Men:::Piano Simulator 2016:::House (W.I.P) Link to comment Share on other sites More sharing options...
fhl42 Posted November 3, 2017 Author Share Posted November 3, 2017 (You could also try releasing after hiding ) Its working thanks you people for helping Script.health = 15.0 --float "Health" Script.useOnce = true --bool "Use once" Script.ReleaseTimer=0 Script.ReleaseDelay=5000--float "Corpse Time" function Script:Start() if self.health < 0 then error("Health can't be a negative value.") end end function Script:UpdatePhysics() if self.ReleaseTimer ~= 0 and self.ReleaseTimer < Time:GetCurrent() then self.entity:Release() end end function Script:Use(player) if player.script.health < player.script.maxHealth then player.script:ReceiveHealth(self.health) if self.useOnce then self.entity:Hide() self.ReleaseTimer = Time:GetCurrent() + self.ReleaseDelay end end end 1 1 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.