Jump to content

Attempt to concatenate local 'name' (a nil value)

Recommended Posts

I'm trying to create a character that transforms into a deerclops, the deerclops part works but every time I try to change the character back to normal I get this error. [string "scripts/entityscript.lua"]:63: attempt to concatenate local 'name' (a nil value)

Here's my code: 

local function becomesmall(inst)
    inst.Large = false
    inst.Transform:SetScale(0.7, 0.7, 0.7)

local function becomelarge(inst)
    inst.Large = true
    inst.AnimState:PlayAnimation("idle_loop", true)
    inst.Transform:SetScale(1.2, 1.2, 1.2)


local becomeformtreshold = (30)
local unbecomeformtreshold = (80)
local function sanity_event_listener(inst, data)
    if inst.components.sanity.current <= becomeformtreshold and not inst.large then        
    elseif inst.components.sanity.current >= unbecomeformtreshold and inst.large then        

Link to comment
Share on other sites

Looking at the entityscript.lua, what's happening is that SetStateGraph(name) calls LoadStateGraph(name), and for some reason "name" is nil when it gets to LoadStatGraph(naeme). It's because you call the SetStateGraph function using . (period) instead of : (colon). Your "SGdeerclopsplay" works, because you use the colon there.

Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Create New...