Logan Whetzel
Logan Whetzel

Reputation: 73

fix error attempt to perform arithmetic (add) on string

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()) <---- here
    hit:remove()
end
connection = script.Parent.Touched:connect(onTouched)

but i got " attempt to perform arithmetic (add) on string error "in line 10 can you fix this error pls?

Upvotes: 1

Views: 494

Answers (1)

Vinni Marcon
Vinni Marcon

Reputation: 616

if hit:GetFullName() is returning a string, in Lua, we use two dots .. to concatenate two strings instead of the plus +:

print("removing " .. hit:GetFullName())

Upvotes: 2

Related Questions