Script not working for some reason

local Debounce = false
local function point(enemypart)
	if Debounce == false then 
		Debounce = true

		for i , v in ipairs(enemypart.Parent.Parent:GetDescendants()) do
			if v.Name == "Aim" then
				script.Parent.Parent.Union.CFrame = , , v.WorldPosition.Y , 0 ))
		Debounce = false



The script is constrainted to an anchored part that is moveing with TweenService, and is in a specific collision grroup so it only collides with a different part that is also constrainted to an anchored part being moved with tweenService. My problem is that it does not seem to detect collisions with the objects.

I’m not sure if I understood what you mean by “constained” correctly, I’m assuming you mean that script.Parent.Parent.Range is the anchored part that is moving by a tween

tweens don’t use physics, so they do not trigger collisions, it’s like setting the cframe of the part each frame teleporting it

you could use body movers to move the part so it can trigger collisions, or check part:GetTouchingParts() after each physics step for collisions

Do you think you could give a bit more detail on what’s wrong with the script? Like a line of error or more explanation on what it is supposed to do. Thanks

1 Like

The issue is with the tweening. Tweening doesnt trigger .Touched
you should replace the tweening with something like using a bodyVelocity or alignPosition

AlignPosition works best for this, so if you use an alignPosition, you’d align Range with an invisible and uncollidable part that is being tweened
the alignPosition would also have RigidityEbabled set to true


My problem is that b and c never show up in the output. Which leads me to believe the collisions arent being registered