How do i fix this ClickDetector "stuttering (idk what to even call this)"?

So i have a ClickDetector hitbox to select a door in my game. If not that obvious, the Camera’s CFrame is lerped to a parts CFrame, then lerps to another part which is facing the door when the mouse enters the hitbox. My issue is when the mouse enters the hitbox, it does this

(ignore the little black rectangle its a glitch from the recording software and not in the game)

https://gyazo.com/c876f07520f90b125539a8e1881c4c74

Why does this happen? And how do i fix this? I’ll provide the script if needed.

idk if i understand this but it looks like in the video the mouse is getting moved off the hitbox once the camera faces it

1 Like

that can be it but i just need a way to stop it

It looks like the camera movement upon looking at the door is pushing your mouse out of the door; which triggers the MouseHoverLeave event.

You could put a bigger invisible part in-front of the door and handle the hover from there. Or you could make the camera fully transition to the door but you can still see the door next to it and hover over that instead.

Now that you know the issue, it really shouldn’t be difficult to come up with a solution. Don’t expect the forums to do everything for you.

Hope this helps.

2 Likes

This is the Scripting Support forum. Please copy/paste the relevant code here with 3 backticks (```) before and after so the formatting stays the same.

It may be a simple thing to see if we can have a look at the section of code that does this transfer.

Looks easy to fix … going to have to see the script however.

1 Like

You should insert relevant parts of the script, it will help us find the problem!

1 Like
	if workspace.Values.VEIL_LDOOR.Value == true then
		-- Create and store the tween for the breathing sound volume increase
		VeilBreathingTween = TweenService:Create(DoorHighlight.Parent.EntitySoundPart.VeilBreathing, TweenInfo.new(5, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {Volume = 0.04})
		VeilBreathingTween:Play()
		DoorHighlight.Parent.EntitySoundPart.VeilBreathing:Play()
	end

	-- Other Hover Enter logic...
	HoverShake()
	UI.Hover:Play()
	UI.HoverOut:Stop()		
	UI.MovementIn:Play()
	UI.Movement:Play()

	-- Toggle Scripts
	UI.Front.Disabled = true
	UI.LeftDoor.Disabled = false
	UI.RightDoor.Disabled = true
	UI.CenterDoor.Disabled = true

	-- UI Tweens
	local fadeIn = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
	TweenService:Create(BottomGrad, fadeIn, { ImageTransparency = 0 }):Play()
	TweenService:Create(FxGradient, fadeIn, { ImageTransparency = 0 }):Play()
	TweenService:Create(ActionKey, fadeIn, { ImageTransparency = 0.6 }):Play()
	TweenService:Create(LeftDoorAction, fadeIn, { TextTransparency = 0.3, TextStrokeTransparency = 0.3 }):Play()

	-- Camera & Highlight Tweens
	TweenService:Create(CurrentCamera, TweenInfo.new(1.3, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), { FieldOfView = 76 }):Play()
	TweenService:Create(DoorHighlight, fadeIn, { OutlineTransparency = 0.5, FillTransparency = 0.9 }):Play()

	-- Light Tweens
	LightLeft.Parent.Base.LightBuzz.PlaybackSpeed = 0
	LightLeft.Parent.Base.LightBuzz.Volume = 0
	LightLeft.Parent.Base.LightOn:Play()
	LightLeft.Parent.Base.LightBuzz:Play()
	TweenService:Create(Light.Parent.Parent.Base.LightBuzz, TweenInfo.new(2, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {Volume = 0.2}):Play()
	TweenService:Create(Light.Parent.Parent.Base.LightBuzz, TweenInfo.new(2, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {PlaybackSpeed = 1.3}):Play()
	TweenService:Create(LightLeft, fadeIn, { Color = Color3.fromRGB(255, 255, 255) }):Play()
	TweenService:Create(Light, fadeIn, { Brightness = 2.56 }):Play()
	TweenService:Create(LightCenter, fadeIn, { Color = Color3.fromRGB(0, 0, 0) }):Play()
	TweenService:Create(LightRight, fadeIn, { Color = Color3.fromRGB(0, 0, 0) }):Play()
	TweenService:Create(SpotLightCenter, fadeIn, { Brightness = 0 }):Play()
	TweenService:Create(SpotLightRight, fadeIn, { Brightness = 0 }):Play()
end)

-- Mouse Hover Leave
Hitbox.MouseHoverLeave:Connect(function()
	-- If the VeilBreathing tween is still playing, stop and cancel it
	if VeilBreathingTween then
		VeilBreathingTween:Cancel()
	end

	-- Fade out the VeilBreathing sound smoothly
	local VeilBreathingFadeOutTween = TweenService:Create(DoorHighlight.Parent.EntitySoundPart.VeilBreathing, TweenInfo.new(0.5, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), {Volume = 0})
	VeilBreathingFadeOutTween:Play()

	-- Other Mouse Hover Leave logic...
	UI.Movement:Play()
	UI.MovementOut:Play()
	HoverShake()
	local fadeIn = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)

	-- Light Tweens
	LightLeft.Parent.Base.LightBuzz.PlaybackSpeed = 0
	LightLeft.Parent.Base.LightOn:Stop()
	LightLeft.Parent.Base.LightBuzz.Volume = 0
	LightLeft.Parent.Base.Off:Play()
	LightLeft.Parent.Base.LightBuzz:Stop()

	TweenService:Create(Light, fadeIn, { Brightness = 0 }):Play()
	TweenService:Create(LightCenter, fadeIn, { Color = Color3.fromRGB(0, 0, 0) }):Play()
	TweenService:Create(LightRight, fadeIn, { Color = Color3.fromRGB(0, 0, 0) }):Play()
	TweenService:Create(LightLeft, fadeIn, { Color = Color3.fromRGB(0, 0, 0) }):Play()
	TweenService:Create(SpotLightCenter, fadeIn, { Brightness = 0 }):Play()
	TweenService:Create(SpotLightRight, fadeIn, { Brightness = 0 }):Play()

	UI.HoverOut:Play()
	UI.Hover:Stop()

	-- Toggle Scripts
	UI.Front.Disabled = false
	UI.LeftDoor.Disabled = true
	UI.RightDoor.Disabled = true
	UI.CenterDoor.Disabled = true

	-- UI Tweens
	local fadeOut = TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.Out)
	TweenService:Create(BottomGrad, fadeOut, { ImageTransparency = 1 }):Play()
	TweenService:Create(FxGradient, fadeOut, { ImageTransparency = 1 }):Play()
	TweenService:Create(ActionKey, fadeOut, { ImageTransparency = 1 }):Play()
	TweenService:Create(LeftDoorAction, fadeOut, { TextTransparency = 1, TextStrokeTransparency = 1 }):Play()

	-- Camera & Highlight Tweens
	TweenService:Create(CurrentCamera, TweenInfo.new(2, Enum.EasingStyle.Quint, Enum.EasingDirection.Out), { FieldOfView = 90 }):Play()
	TweenService:Create(DoorHighlight, fadeOut, { OutlineTransparency = 1, FillTransparency = 1 }):Play()

	Hitbox.MaxActivationDistance = 0
	wait(0.5)
	Hitbox.MaxActivationDistance = 500
end) ```

interaction system
1 Like
	local camera = workspace.CurrentCamera
	local head = workspace.CamParts.LeftDoor
	local maxDegree = math.rad(2)
	camera.CameraType = Enum.CameraType.Scriptable
	local mouse = game.Players.LocalPlayer:GetMouse()
	local center = Vector2.new(camera.ViewportSize.X / 2, camera.ViewportSize.Y / 2)
	local diff = Vector2.new(mouse.X, mouse.Y) - center

	local unit = Vector2.new((diff.Y / center.Y) * maxDegree, (-diff.X / center.X) * maxDegree) 
	local newOrientation = CFrame.Angles(unit.X, unit.Y, 0) * CFrame.Angles(math.rad(head.Orientation.X), math.rad(head.Orientation.Y), math.rad(head.Orientation.Z))
	camera.CFrame = camera.CFrame:lerp(CFrame.new(head.Position) * newOrientation, 0.1)
	head.Transparency = 1
end

game:GetService("RunService").RenderStepped:Connect(updateCameraLerp)```

the camera it moves too when focused.
1 Like

my guess : add a cooldown

source : i forgot

Hm, that’s a tough nut to crack. Maybe try to delete (or put -- behind the line of code, so you can restore it):

camera tweens, and it shouldn’t move if the correct line was “deleted”.

Hope this helps! : )