Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why is this script not detecting TouchEnded correctly? (solved)

This is not all the script but when a button is clicked it spawns a vehicle and a box around it (CanCollide is off). When the vehicle leaves the box, its supposed to remove the box and allow the vehicle to be regenerated. However this does not work and the box remains after the vehicle has left it (Stopped Touching it)

while Workspace:FindFirstChild("RegenSingleBox") do -- Name of box
	wait(1)
	Workspace:FindFirstChild("RegenSingleBox").TouchEnded:connect(function(NoTouch)
		return true
	end) -- If there is nothing touching the box then return true
	
	if NoTouch() == true then -- if theres nothing touching, destroy the box
		Workspace:FindFirstChild("RegenSingleBox"):Destroy()
		script.Parent.BrickColor = BrickColor.new(1031) 
	end

end

MD

EDIT: Asked on ROBLOX forums and was given a different way of solving the problem.

1 comment

0

maybe the box is touching the floor?

1 answer

This discussion is preserved as it was. New answers, comments, and votes are closed.