Hello, I'm trying to make a script that when you hit a part named "Vetro" the part destroys. I'm doing it serverside.
I get the error "Attempt to index nil with "IsA"?" and I don't understand why I can't fix it.
Take note that that's a RemoteEvent, that's why I've put the if statement.
ServerSide script:
if t == "w" then local function vetro(hitted) if hitted:IsA("BasePart") and hitted.Name == "Vetro" and hitted.Transparency > 0 then hitted:Destroy() end end vetro() end
ClientSide script part:
function vetro() script.Parent.Event:FireServer("w") end
I've also tried changing "IsA" with ClassName but still getting an error. Can someone help me please?
if t == "w" then local function vetro(hitted) if typeof(hitted) == "Instance" and hitted:IsA("BasePart") and hitted.Name == "Vetro" and hitted.Transparency > 0 then hitted:Destroy() end end vetro() end
I've added typeof() to check if it is an Instance and not a string. May help