Pressure plate activated door not working correctly

Hello, I recently got a door script working where the player needs to place an item in a folder on a pressure plate and then activate a prox promt which triggers a script to detect if the item from the folder is on the pressure plate or not. if it is then the doors will open.

This script was working when I first made it but now (a few months later) it only works when the object is either partially off the detecting part or if its small and rolling over the detecting part (pressure plate). (Depicted in image below vvv)

Could anyone please recommend or show me how I fix this problem and make it so that it detects the object no matter if its still or fully on the pressure plate?

Code from door script below vvvv

speed = 0.30

door1 = script.Parent.SlidingDoor1
door2 = script.Parent.SlidingDoor2
prompt = script.Parent.Parent.ProxP.ProximityPrompt
open = script.Parent.Oppen
lightpart = script.Parent.Parent.LightPart
objectTouching = false

--Detects whether the "object" is touching the part named "oppen"
open.Touched:Connect(function(Hit)
	if Hit.Name == "Object" then
		objectTouching = true
	end
end)

open.TouchEnded:Connect(function(Hit)
	if Hit.Name == "Object" then
		objectTouching = false
	end
end)

--Main Script Starts Here
prompt.Triggered:Connect(function(player)
	if objectTouching then
		prompt.Enabled = false

		wait(.5)
		script.Voice:Play()
		wait(1)
		lightpart.Color = Color3.fromRGB(55, 176, 55)
		script.Approved:Play()

		wait(.1)

		--This loop moves the two doors away from each other 
		--so the player can pass through

		script.OpenSound:Play()
		for i=1,(door1.Size.z/speed) + 1 do
			wait()
			door1.CFrame = door1.CFrame - (door1.CFrame.lookVector * speed)
			door2.CFrame = door2.CFrame - (door2.CFrame.lookVector * speed)
		end



	end
end)

Ill also link the full model soon

1 Like

I think this is something to do with it firing a Touched event and a TouchEnded event near enough the same time, you could try something a bit like what is done here

Sorry, Iā€™m not the best scripter. What code from this link would be useful to use?