How do I check for a Part or Instance, that has Not been created in the workspace?

The First script Prints "Touch" if the "BluePart" is being Touched By the "RedPart". And the Second Script makes the " RedPart" and puts it into the workspace.

The Problem is I dont know how to Check if the "RedPart" is in the workspace.

local bluePart = workspace.BluePart
local redPart = workspace:WaitForChild("RedPart")

local isTouching

local function onTouched(otherpart)
	if otherpart == redPart then
		print "Touch"
		isTouching = true
	end
end

part.Touched:Connect(onTouched)

and the Instance to create RedPart

local RedPart = Instance.new("Part")

RedPart.Parent = workspace
RedPart.Name = ("RedPart")
RedPart.CanCollide = True
RedPart.BrickColor = BrickColor.new("Really red")

3 comments

0

On the instance to create a Red Part, you spelt Workspace wrong. Though I'm afraid I don't understand your question.

0

I don't get the problem

0

Use FindFirstChild