It should be like:
if getContainerItem(demoncorpse.uid, magicswordID) == true then
setGlobalStorageValue(magicswordID, (getGlobalStorageValue(magicswordID)+1))
end
Try an onUse() like
local demonid = xxxx --corpseID
local ms = xxxx --magic sword ID
function onUse(cid, item, fromPosition...