How do i fix this localscript

heres the script

local UserInputService = game:GetService(“UserInputService”)

local mousePosition = UserInputService:GetMouseLocation()

task.wait(3)

print(mousePosition)

in output it only says -1, -1 please someone help

heres the script

in output it only says -1, -1

This happens because the script runs so fast it makes the mousePosition variable before your mouse loads in

to fix this you should place the mousePosition variable below the task.wait(3) line

1 Like
local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()
local MousePos = Vector2.new(Mouse.X, Mouse.Y)
1 Like

local UserInputService = game:GetService(“UserInputService”)

task.wait(3)

local mousePosition = UserInputService:GetMouseLocation()

print(mousePosition)

1 Like

yep that’s how you do it, if your game takes more than 3 seconds to load consider increasing the wait timer

it works when i write this, thanks for helping

now its says this
image
instead of -1, -1

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.