How come mouse is nil?

local Players = game:GetService("Players")

local Player = Players.LocalPlayer 

local Mouse = Player:GetMouse()

local Button = script.Parent

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local RemoteFolder = ReplicatedStorage:WaitForChild("Remotes")

local EnemyFolder = ReplicatedStorage:WaitForChild("Enemies")

local Remote = RemoteFolder:WaitForChild("Remote1")

Button.MouseButton1Down:Connect(function(x, y, Mouse)
	Remote:FireSever()
end)

When I try to index the Mouse Parameter it just says “attempt to index local mouse a nil value”

1 Like

In your MouseButton1Down function, you’re shadowing Mouse in the parameter list. So if you try to use Mouse within that function, it will be nil.

6 Likes

Moreover, i’m confused why having Mouse when (x, y) are the only real Parameters,

so yea, you can just remove it as it defines nothing.

Button.MouseButton1Down:Connect(function(x, y)
	print(x.." "..y.." "..Mouse)
end)