• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!
  • 2026 staff recruitment is open! Check it out and consider applying!

tfs 1.2 script

guys im getting an error in function name attempt to call local name a string value

Code:
local monster = {
    ['dragon'] = 123456
}

function onKill(creature, target)
    if creature:isPlayer() and target:isMonster() then
        local name = target:getName():lower()
        if monster[name] then
            local storage = creature:getStorageValue(monster[name])
            local count = math.max(0, storage) + 1
            creature:setStorageValue(monster[name], count)
            creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. count .. "x " .. name ".")
        end
    end
    return true
end
 
that is screenshot of error
Code:
local monster = {
    ['dragon'] = 123456
}

function onKill(creature, target)
    if creature:isPlayer() and target:isMonster() then
        local name = target:getName():lower()
        if monster[name] then
            local storage = creature:getStorageValue(monster[name])
            local count = math.max(0, storage) + 1
            creature:setStorageValue(monster[name], count)
            creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. count .. "x " .. name .. ".")
        end
    end
    return true
end
 
Code:
local monster = {
    ['dragon'] = 123456
}

function onKill(creature, target)
    if creature:isPlayer() and target:isMonster() then
        local name = target:getName():lower()
        if monster[name] then
            local storage = creature:getStorageValue(monster[name])
            local count = math.max(0, storage) + 1
            creature:setStorageValue(monster[name], count)
            creature:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, "You have killed " .. count .. "x " .. name .. ".")
        end
    end
    return true
end
corrected thanks
 
Back
Top