修复错误:尝试在字符串上执行算术操作(加法)

if (hit.Name == "Base") then return end
   hit:BreakJoints()
   if (hit.Anchored == true) then hit.Anchored = false end
   wait(.5)
   for i=1, 10 do
        hit.Transparency = hit.Transparency + 0.1
        wait(0.2)
    end
    print("removing" + hit:GetFullName()) <---- 这里
    hit:remove()
end
connection = script.Parent.Touched:connect(onTouched)

但在第10行出现了"尝试在字符串上执行算术操作(加法)"的错误,请问能否修复这个错误?

点赞
用户12568711
用户12568711

如果hit:GetFullName()返回一个string,在Lua中,我们使用两个点..连接两个字符串,而不是加号+

print("removing " .. hit:GetFullName())
2020-09-01 02:54:58