if someone could help me create i would be veri happy. Thanks in advanced
EDITED AFTER SOLUTION WAS FOUND :
the solution leans to the right a lot because it thinks the center of the screen is farther to the left, so I found that replacing
local X = InputObject.Position.X - (ScreenGui.AbsoluteSize.X / 2) + (ViewportFrame.AbsoluteSize.X / 2)
local Y = InputObject.Position.Y - (ScreenGui.AbsoluteSize.Y / 2) + (ViewportFrame.AbsoluteSize.Y / 2)
with
local middleOfScreen = Vector2.new(workspace.CurrentCamera.ViewportSize.X / 2, workspace.CurrentCamera.ViewportSize.Y / 2 - (game:GetService("GuiService"):GetGuiInset().Y/2))
print(middleOfScreen)
local X = InputObject.Position.X - middleOfScreen.X
local Y = InputObject.Position.Y - middleOfScreen.Y
I came up with this, the mouse’s cursor can be changed upon entry/exit of the viewport frame through its ‘MouseEnter’ and ‘MouseLeave’ signals.
local Enumeration = Enum
local Game = game
local TweenService = Game:GetService("TweenService")
local Script = script
local ScreenGui = Script:FindFirstAncestorOfClass("ScreenGui")
local ViewportFrame = ScreenGui:FindFirstChildOfClass("ViewportFrame")
local Part = ViewportFrame:FindFirstChild("Part")
local function OnInputChanged(InputObject, GameProcessed)
if GameProcessed then return end
if InputObject.UserInputType ~= Enumeration.UserInputType.MouseMovement then return end
local X = InputObject.Position.X - (ScreenGui.AbsoluteSize.X / 2) + (ViewportFrame.AbsoluteSize.X / 2)
local Y = InputObject.Position.Y - (ScreenGui.AbsoluteSize.Y / 2) + (ViewportFrame.AbsoluteSize.Y / 2)
X = (X - 210) / 30
Y = (Y - 210) / 30
local Tween = TweenService:Create(Part, TweenInfo.new(0.2, Enumeration.EasingStyle.Linear, Enumeration.EasingDirection.Out), {Orientation = Vector3.new(Y, X, 0)})
Tween:Play()
end
ViewportFrame.InputChanged:Connect(OnInputChanged)
Here’s the place file if you need to inspect further. Gui.rbxl (29.0 KB)
This would be cool to, if the mouse was not inside of the box, like somewhere else on the screen… there was a delay like 4 seconds, and then the inner area would reset to a straight perfect position, like when it started…
instead of when you are out of it, it is off centered …