Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How can I get a hopperbin to get the mouse and then disappear?


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?

1 comment

0

Why not use Player:GetMouse() instead of hopperbins?

2 answers

Add this above function

Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()

1 comment

0

You 'May' have to change script to LocalScript.

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.

  1. Make a GUI
  2. Make a TextLabel
  3. Make TextLabel Text Scaled
  4. Put a LocalScript in the TextLabel with this Code...
Mouse = game.Players.LocalPlayer:GetMouse()
while true do
wait(.01)
if Mouse.Target then
script.Parent.Text = Mouse.Targret.Name
end
end

This discussion is preserved as it was. New answers, comments, and votes are closed.