So im trying to make an effect when a part touches the ground however i keep getting this error "Workspace.Ball.Script:8: attempt to index a nil value"
script.Parent.Touched:Connect(function(hit)
wait(1)
game.Workspace.Ball:Clone().Parent = game.Workspace
if hit.Parent.Name == 'Balls' then
game.Workspace.Ball:Remove().Parent = game.Workspace
--effects go here
elseif hit.Parent.Name ~= nil then
game.Workspace.Ball:Remove().Parent = game.Workspace
--effects go here
end
end)

2 comments
Because you are removing the ball then you are trying to index the
Parentof the ball then set itAlso
Removeis a deprecated method