Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

When adding a circle GUI, how do I make the mouse consigned to the circle?

To elaborate more, I'm working on a fighter jet and I'd like to find how to make sure the mouse can't move out of a small circle in the centre of the screen (hopefully you see what I mean)

Any solutions would be helpful!

1 answer

✓ Accepted answer

this will only show the moving box or circle

local Uis = game:GetService("UserInputService")
local RunS = game:GetService("RunService")
local Frame = script.Parent.Frame
local Sensitivity = 1 --above one for more sensitivity i think
RunS.Stepped:Connect(function()
	Uis.MouseBehavior = Enum.MouseBehavior.LockCenter
	Uis.MouseIconEnabled = false
	local Delta = Uis:GetMouseDelta()
	Uis.MouseDeltaSensitivity = Sensitivity
	--script.Parent.Frame.Position = UDim2.new(.5,-Delta.X,.5,-Delta.Y)
	game:GetService("TweenService"):Create(Frame,TweenInfo.new(.1),{Position = UDim2.new(.5,-Delta.X,.5,-Delta.Y)}):Play()
end)

1 comment

0

thanks, i'll test it out

This discussion is preserved as it was. New answers, comments, and votes are closed.