I'm trying to check if a part has touched another part and if it has, delete the part(itself) after that but roblox studio keeps crashing every time I try to do that.
local ball = script.Parent
while true do
wait(.5)
repeat
local newball = Instance.new("Part")
newball.Parent = game:GetService("Workspace")
newball.Size = Vector3.new(41.599, 9.74, 52.861)
newball.CFrame = CFrame.new(-71.199, 203.093, 59.05)
newball.Anchored = false
newball.Color = Color3.fromRGB(165, 0, 2)
newball.CanCollide = true
newball.Touched:Connect(function()
if newball:FindFirstChild("Baseplate") == true then
newball:Destroy()
end
end)
until ball.Position == Vector3.new(0, -8, 0)
end

2 comments
Are you using any loops in your code?
Maybe try a loop?