Trying to understand how mouse events work

local player = game.Players.LocalPlayer
local mouse = player:GetMouse()

mouse.Move:Connect(function()
	print(mouse.X, mouse.Y)
end)

I’ve been trying for an hour to get this script to work, its even copied off a youtube video and it still wont work. If somebody could give some feedback or tell me whats wrong that would be great, thanks…

1 Like

A few questions.

  1. What script type is it (Server, Local, Module)?
  2. Where is it located?
  3. Are you sure it is not disabled?
1 Like


hope this answers all those questions…
its not disabled and its a local script located in workspace

This script works perfectly fine for me. It could be that it is not a local script, etc. Make sure this is a local script and is in StarterGui or StarterPlayer.

local scripts do not work inside of Workspace.

2 Likes

LocalScripts don’t run in Workspace unless they are a descendant of a player’s Character. Move it to PlayerScripts.

2 Likes

Copy pasted from this
A LocalScript will only run Lua code if it is a descendant of one of the following objects:

  • A Player’s Backpack , such as a child of a Tool
  • A Player’s character model
  • A Player’s PlayerGui
  • A Player’s PlayerScripts .
  • The ReplicatedFirst service
1 Like

okay thank you… i didnt know they had to be in StarterGui or StarterPlayer. thank you so much for your help kind sir

1 Like