Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

I keep getting an error for a line. Why?

Asked by 9 years ago

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)

1 answer

Log in to vote
1
Answered by
adark 5487 Badge of Merit Moderation Voter Community Moderator
9 years ago

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)

1
What good does it do to check if the mouse's x coordinate exists? Perci1 4988 — 9y
0
Nothing, I misread the error in his script. Woops. :P adark 5487 — 9y
Ad

Answer this question