UI Animation Intervening with cursor position

Hello guys!

I have a slight problem with this UI Animation intervening with the position of the cursor.

Video showing the issue:
https://i.gyazo.com/132f0943d64ad423faec907ec0a1d84c.mp4

I have tried looking for a property, within the UI, that might have something to do with unlocking the mouse when holding the right click. Didnt find anything so hoping someone out there could help! :smiley:

Here is the code I’m using:

local animTime = .15
local delay = 2

function CC.Spawn()
	local ClickCircle = ccUI:Clone()
	
	local endSize = ClickCircle.Size
	local pos = UIS:GetMouseLocation()
	
	ClickCircle.Position = UDim2.new(0,pos.X,0,pos.Y-36)
	ClickCircle.Size = UDim2.new(0,0,0,0)
	ClickCircle.Parent = plr.PlayerGui.ScreenGui
	
	ClickCircle:TweenSize(endSize, Enum.EasingDirection.In, Enum.EasingStyle.Linear, animTime)
	
	task.wait(animTime/delay)
	
	local Info = TweenInfo.new(animTime-animTime/delay)
	local Tween = game:GetService("TweenService"):Create(ClickCircle, Info,{BackgroundTransparency=1})
	Tween:Play()
	
	Tween.Completed:Wait()
	
	ClickCircle:Destroy()
end
1 Like

UserInputService.MouseBehavior

Also, make sure Active is false on the ccUI.

This doesn’t seem to fix the problem.

I tried adding this if statement:

	if holdingRightClick then
		UIS.MouseBehavior = Enum.MouseBehavior.LockCurrentPosition
	end

But yea doesn’t seem to do anything I suspect that it’s because the current position of the mouse is already locked but the mouse move function within Roblox is still trying to move the mouse while it’s locked. Also explains why it’s jittering back and forth sometimes in the video.

Thank you for the reply though. :smiley:

You can make the click circle appear at the locked mouse position by creating a variable which stores the mouse position when UserInputService.MouseBehavior is set to LockCurrentPosition and setting the mouse position variable to nil when UserInputService.MouseBehavior is not set to LockCurrentPosition

local LockedMouseLocation = nil

RunService.RenderStepped:Connect(function()
	if UIS.MouseBehavior == Enum.MouseBehavior.LockCurrentPosition then
		if LockedMouseLocation == nil then
			LockedMouseLocation = UIS:GetMouseLocation()
		end
	else
		LockedMouseLocation = nil
	end
end)

And if the mouse position variable is not equal to nil then use it as the position for the click circle

1 Like

Is it possible that the circle is a button?

At the moment I’m using a frame. Should I use a button?

No, it should be a frame. Does the frame have a button inside of it?

This does work actually but… Unfortunately, there’s still this annoying mouse stuttering between the locked position and the actual mouse position.

https://i.gyazo.com/dee1a8f5ee1ff48e695f1cb98a7d9580.mp4

Very interesting method though :smiley:

You should try using only one frame instead of cloning.