Goregonzola Posted January 19, 2021 Share Posted January 19, 2021 (edited) Ladies and Gentleman, Please welcome today evening's "What have I coded wrong?" show's brand new guest: Character scaling! So, I've been tinkering with this coding for a while now, but I can't figure out what do I code wrong: Spoiler local function greatestevil(inst) local health = inst.components.health.current if inst:HasTag("playerghost") then return end if inst.components.health:IsDead() then return end -- stage I if health <= 150 then inst.Transform:SetScale(1.2, 1.2, 1.2) end -- stage II if health >= 151 and health <= 350 then inst.Transform:SetScale(2.2, 2.2, 2.2) end -- stage III if health >= 351 and health <= 500 then inst.Transform:SetScale(3.2, 3.2, 3.2) end -- stage IV if health >= 501 then inst.Transform:SetScale(4, 4, 4) end end local master_postinit = function(inst) inst:ListenForEvent("healthdelta", greatestevil) inst.OnNewSpawn = function(inst) Health:SetCurrentHealth(150) end It crashes the game and it says: attempt to compare nil with number (here: if health <= 150 then) Help my poor soul. Edited January 20, 2021 by BillTheCipher Link to comment https://forums.kleientertainment.com/forums/topic/126278-solved-unsuccesful-character-scaling/ Share on other sites More sharing options...
Thomas_klei Posted January 19, 2021 Share Posted January 19, 2021 (edited) local health = inst.components.health:GetCurrent() try this one instead Edited January 19, 2021 by thomas4846 Link to comment https://forums.kleientertainment.com/forums/topic/126278-solved-unsuccesful-character-scaling/#findComment-1418464 Share on other sites More sharing options...
penguin0616 Posted January 19, 2021 Share Posted January 19, 2021 (edited) health.current == nil health.currenthealth ~= nil @thomas4846 Supposed to be a : not . , and GetCurrent isn't a valid member of health. Edited January 19, 2021 by penguin0616 2 Link to comment https://forums.kleientertainment.com/forums/topic/126278-solved-unsuccesful-character-scaling/#findComment-1418465 Share on other sites More sharing options...
Thomas_klei Posted January 19, 2021 Share Posted January 19, 2021 is it GetCurrentHealth()? or like GetHealthCurrent() 1 Link to comment https://forums.kleientertainment.com/forums/topic/126278-solved-unsuccesful-character-scaling/#findComment-1418466 Share on other sites More sharing options...
penguin0616 Posted January 19, 2021 Share Posted January 19, 2021 There isn't a method to return current health, you have to specifically check the member. 2 1 Link to comment https://forums.kleientertainment.com/forums/topic/126278-solved-unsuccesful-character-scaling/#findComment-1418480 Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now