Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How to check if part has touched another and delete with while true do loop? [closed]

Asked by 2 years ago
Edited 2 years ago

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


0
Are you using any loops in your code? ghostbettert 30 — 2y
0
Maybe try a loop? 2mania 14 — 2y

Closed as Non-Descriptive by JesseSong

This question has been closed because its title or content does not adequately describe the problem you are trying to solve.
Please ensure that your question pertains to your actual problem, rather than your attempted solution. That is, you were trying to solve problem X, and you thought solution Y would work, but instead of asking about X when you ran into trouble, you asked about Y.

Why was this question closed?