Alternate way to detect Touched event on Tweened part?

Hi, I’m trying to make a part guarding a small room where it’s been enlarged to act as hitbox. However, I noticed that Touched event don’t work with currently playing tweened parts and I tried looking up articles for help but none of them really helped. Is there a different way that I can make this work?

My localscript for it:

local localplayer = game:GetService("Players").LocalPlayer
local tweenservice = game:GetService("TweenService")
local debounce = true
local cam = workspace.Camera
local viewport_size = cam.ViewportSize

local goalfirst = {}
goalfirst.Position = Vector3.new(-775.391, 7.435, 771.918)

local goalsecond = {}
goalsecond.Position = Vector3.new(-775.391, 7.435, 674.918)

local goalthird = {}
goalthird.Position = Vector3.new(-826.391, 7.435, 674.918)

local goalfourth = {}
goalfourth.Position = Vector3.new(-826.391, 7.435, 771.418)

local goalfinal = {}
goalfinal.Position = Vector3.new(-936.891, 7.435, 771.418)

local goalteleport = {}
goalteleport.Position = Vector3.new(-674.891, 7.435, 771.918)

local turnright = {}
turnright.Orientation = workspace.sillyguard.Orientation + Vector3.new(0,-90,0)

local turnleft = {}
turnleft.Orientation = workspace.sillyguard.Orientation + Vector3.new(0,89.9,0)

local straight = {}
straight.Orientation = workspace.sillyguard.Orientation + Vector3.new(0,0,0)

local invisible = {}
invisible.Transparency = 1

local visible = {}
visible.Transparency = 0

local tweeninfosilly = TweenInfo.new(3, Enum.EasingStyle.Linear)
local tweeninfosilly2 = TweenInfo.new(1.5, Enum.EasingStyle.Linear)

local tweensilly1 = tweenservice:Create(workspace.sillyguard, tweeninfosilly, goalfirst)
local tweensilly2 = tweenservice:Create(workspace.sillyguard, tweeninfosilly2, turnright)
local tweensilly3 = tweenservice:Create(workspace.sillyguard, tweeninfosilly, goalsecond)
local tweensilly4 = tweenservice:Create(workspace.sillyguard, tweeninfosilly2, turnleft)
local tweensilly5 = tweenservice:Create(workspace.sillyguard, tweeninfosilly, goalthird)
local tweensilly6 = tweenservice:Create(workspace.sillyguard, tweeninfosilly, goalfourth)
local tweensilly7 = tweenservice:Create(workspace.sillyguard, tweeninfosilly, goalfinal)
local tweensilly8 = tweenservice:Create(workspace.sillyguard, tweeninfosilly2, invisible)
local tweensilly9 = tweenservice:Create(workspace.sillyguard, tweeninfosilly2, visible)
local tweensilly10 = tweenservice:Create(workspace.sillyguard, tweeninfosilly2, straight)

while true do
	tweensilly1:Play()
	tweensilly1.Completed:Wait()
	tweensilly2:Play()
	tweensilly2.Completed:Wait()
	tweensilly3:Play()
	tweensilly3.Completed:Wait()
	tweensilly10:Play()
	tweensilly10.Completed:Wait()
	tweensilly5:Play()
	tweensilly5.Completed:Wait()
	tweensilly4:Play()
	tweensilly4.Completed:Wait()
	tweensilly6:Play()
	tweensilly6.Completed:Wait()
	tweensilly10:Play()
	tweensilly10.Completed:Wait()
	tweensilly7:Play()
	tweensilly7.Completed:Wait()
	tweensilly8:Play()
	tweensilly8.Completed:Wait()
	workspace.sillyguard.Position = Vector3.new(-674.891, 7.435, 771.918)
	tweensilly9:Play()
	tweensilly9.Completed:Wait()
end
workspace.sillyguard.Touched:Connect(function(character)
	if debounce == true then
		if character.Parent:FindFirstChild("Humanoid") then
		if localplayer.Character and character:IsDescendantOf(localplayer.Character) then
				debounce = false
				print("touchi")
				tweensilly1:Cancel()
				tweensilly2:Cancel()
				tweensilly3:Cancel()
				tweensilly4:Cancel()
				tweensilly5:Cancel()
				tweensilly6:Cancel()
				tweensilly7:Cancel()
				tweensilly8:Cancel()
				tweensilly9:Cancel()
				tweensilly10:Cancel()
	
				local goal3 = {}
				goal3.CFrame = CFrame.lookAt(cam.CFrame.Position, workspace.sillyguard.Position)

				local tweeninfo3 = TweenInfo.new(1, Enum.EasingStyle.Quart, Enum.EasingDirection.InOut)

				local tween3 = tweenservice:Create(cam, tweeninfo3, goal3)
				workspace.Camera.CameraType = Enum.CameraType.Scriptable
				character.Parent.Humanoid.WalkSpeed = 0
				local camera_ray = cam:ViewportPointToRay(viewport_size.X / 2,viewport_size.Y / 2)

				workspace.sillyguard.CFrame = CFrame.lookAt(workspace.sillyguard.Position,camera_ray.Origin)
				workspace.sillyguard.CFrame = workspace.sillyguard.CFrame:ToWorldSpace(CFrame.Angles(math.rad(90),0,0))
				tween3:Play()
				wait(0.75)
				local goal2 = {}
				goal2.Position = cam.CFrame.Position - Vector3.new(0,5,0)

				local tweeninfo2 = TweenInfo.new(0.25, Enum.EasingStyle.Linear)

				local tween2 = tweenservice:Create(workspace.sillyguard, tweeninfo2, goal2)
				tween2:Play()
				workspace.sillyguard.ghostboo:Play()
				local camera_ray = cam:ViewportPointToRay(viewport_size.X / 2,viewport_size.Y / 2)

				workspace.sillyguard.CFrame = CFrame.lookAt(workspace.sillyguard.Position,camera_ray.Origin)
				workspace.sillyguard.CFrame = workspace.sillyguard.CFrame:ToWorldSpace(CFrame.Angles(math.rad(90),0,0))
				wait(0.25)
				workspace.sillyguard.ghostboo:Stop()
				workspace.sillyguard.Orientation = Vector3.new(90, 90, 0)
				workspace.sillyguard.Position = Vector3.new(-674.891, 7.435, 771.918)
				workspace.Camera.CameraType = Enum.CameraType.Custom
				character.Parent.Humanoid.WalkSpeed = 16
				wait(1)
				debounce = true

				end
			end
		end
end)

What are you trying to detect with the touched event? It should work fine.

The player itself but it doesn’t seem to work. Basically, what I want is when someone runs into the tweened hitbox, the touched event should execute but it doesn’t work because it’s not currently in a physical format.

Look at your if statements they are messed up. Not on mine but on your original post. Thats probably not the problem but still fix that.

No, that’s not the issue. This basically makes it so any Touched events runs only locally. The issue is the workspace.sillyguard.Touched:Connect(function(character) not executing when I’m trying to touch the moving hitbox.

Do you make sure to actually touch it?

Yes? What else would I use apart from Touched?

Well touched isn’t great in a local script, as hackers can exploit it. Is there a problem with making it server sided? Or to at least make the touched event server sided?

You can also use gettouchingparts() and check for a character and humanoid.

My game works solely on local scripts (I know exploiters can abuse it but it wont affect other players.) and I wanna make the code work exclusively inside the local script.

Ok. In that case you can use GetTouchingParts, find the parent, check for and humanoid and if the chars name is the local players name. If that is true then you can run the function.

Pretty sure that won’t work aswell. As I said in the original post, Touched events will not work with Tweened parts and I’m looking for an alternative to it.

Touched is an event that is physics based. Because tweening a part is not physics-based, the script signal is not guaranteed to fire.

To resolve this, you can use workspace:GetPartsInPart() to see what parts are inside of the hitbox.

Is it possible to provide an example? I’v never heard of this object before.

This works 100% exactly the same as GetTouchingParts

Right, I might aswell spend countless hours trying to figure out how to make it work lol.

As @iGottic said, it works exactly as get touching parts. I can help with that if you want.

Sure, If you want.

extrawordsbecauselimit

I’ll send it later.

extrawordsyay

Figured it out, I simply had to put the while true do directly after the Touched event and it works!