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

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

Asked by 10 years ago

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?

0
Why not use Player:GetMouse() instead of hopperbins? 1waffle1 2908 — 10y

2 answers

Log in to vote
0
Answered by
Fatul 9
10 years ago

Add this above function

Player = game.Players.LocalPlayer
Mouse = Player:GetMouse()
0
You 'May' have to change script to LocalScript. Fatul 9 — 10y
Ad
Log in to vote
0
Answered by
MixCorp 70
10 years ago

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

Answer this question