When in first person, how do I get the mouses position (the pointer) on all devices.
Heres the problem I had, the grey frame you see is my previous test, which is constantly wrong, every time I re-enter It decides it wants to not be the middle anymore. Heres the code I used to get the frame:
local mouse = game.Players.LocalPlayer:GetMouse() local f = Instance.new("Frame", game.Players.LocalPlayer.PlayerGui.Freecam) f.AnchorPoint = Vector2.new(.5,.5) f.Position = UDim2.new(0, mouse.X, 0, mouse.Y) f.Size = UDim2.new(.01, 0, 0.01, 0)
I did that in the command bar, this is my result, obviously varying in the new test. (The mouse is no longer in the center of the frame ;/)
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local frame = script.Parent
local function Update()
local position = UDim2.new(0,mouse.X,0,mouse.Y) -- frame.AnchorPoint is .5,.5
frame.Position = position
end
game:GetService("RunService").Heartbeat:Connect(Update)
The thing is, I need the mouse locked in the center of the screen for a “Third Person Shooter” kinda deal. I need to make the mouse transparent, and make custom reticles that should be tweened in/out. I need the middle of the screen so I can raycast properly to then move on. :))