I was just wondering why i keep getting this error when ever i try to run it "Players.Player.PlayerGui.LocalScript:4: attempt to index field 'X' (a number value) 16:29:13.071 - Stack Begin 16:29:13.073 - Script 'Players.Player.PlayerGui.LocalScript', Line 4 16:29:13.074 - Stack End"
local P = game.Players.LocalPlayer local mouse = P:GetMouse() local Icon = game.Workspace.Icon:Clone() mouse.X.Changed:connect(function() end)
Integers do not have a Changed
event, you have to call that on the PlayerMouse
object itself. Additionally, PlayerMouse
object have a Move
event that only fires when the player moves the mouse:
local P = game.Players.LocalPlayer local mouse = P:GetMouse() local Icon = game.Workspace.Icon:Clone() mouse.Move:connect(function() --code end)