function getMouse(Player) local T = Instance.new("Tool",Player.Backpack) local P = Instance.new("Part",T) local Mouse = nil P.Name = "Handle" T.Equipped:connect(function (m) Mouse = m end) T.Parent = Player.Character wait(5) T:Remove() return Mouse end local Mouse = getMouse(game.Players.LocalPlayer) if Mouse ~= nil then Mouse.Button1Down:connect(function () mouseDown(Mouse) end) end print(Mouse.Target) print("FINISHED")
When I do this the script stops at print(Mouse.Target)
saying mouse is nil. Help?
Add this above function
Player = game.Players.LocalPlayer Mouse = Player:GetMouse()
This doesnt really have to be done with a HopperBin, If you make a LocalScript in Player or StarterGui Or Backpack then you can do
Mouse = game.Players.LocalPlayer:GetMouse() print(Mouse.Target)
(P.S) It says its nil if your mouse is pointing at the sky. So if that is a problem, Try this.
Mouse = game.Players.LocalPlayer:GetMouse() while true do wait(.01) if Mouse.Target then script.Parent.Text = Mouse.Targret.Name end end