Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 1 year ago

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

Log in to vote
0
Answered by
Puppynniko 1059 Moderation Voter
1 year ago

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)
0
thanks, i'll test it out Valkyrie1277 28 — 1y
Ad

Answer this question