How to make mouse input? Why is my script is not working?
local Player = game.Players.LocalPlayer local Mouse = Player:GetMouse() Mouse.MouseButton1Click:connect(function() print("LOL") end)
Your issue is you're using a clickEvent
ment for a Gui Object meaning it will fire when a Gui was click by the mouse, you should be using Button1Down
instead for as the default event
local player = game:GetService("Players").LocalPlayer --// more efficient method, use this local cursor = player:GetMouse --// I prefer cursor:) cursor.Button1Down:Connect(function() pcall(function() print(cursor.Hit.p.." - '"..cursor.Target.Name.." ("..cursor.Target.ClassName) --// try this out end) end)
mouse.Hit.p will give you a Vector3 position of the mouse in a 3D worldspace, this is useful in some scenarios.
mouse.Target is what the mouse is hovering over, sometimes this can be nil so we use pcall to make sure the script keeps running