generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Teleport Hopperbin not working [LOCAL SCRIPT]

Previous Thread :: Next Thread 
12packkid is not online. 12packkid
Joined: 24 Jun 2011
Total Posts: 1418
23 Feb 2013 07:45 AM
-- This is a localscript that is in a hopperbin, and when I test it, the output says "MouseButton1Click is not a member of PlayerMouse"


g=game.Players.LocalPlayer:GetMouse()
p=game.Players.LocalPlayer

g.MouseButton1Click:connect(function(cl)
p.Character.Torso.CFrame=cl.Target
end)
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
23 Feb 2013 07:46 AM
Exactly what it says. MouseButton1Click is not a valid member (=property / event / method) of mouse.

So...

http://wiki.roblox.com/index.php/Mouse

See if you can find your error :)
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
23 Feb 2013 07:51 AM
Mouse.MouseButton1Down sounds dumb, thus it'

Mouse.Button1Down
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
23 Feb 2013 07:52 AM
You spoiled it! ;)
Report Abuse
12packkid is not online. 12packkid
Joined: 24 Jun 2011
Total Posts: 1418
23 Feb 2013 07:54 AM
--Improved version, but Im still getting errors, and it won't teleport either.


script.Parent.Selected:connect(function(mouse)

g=game.Players.LocalPlayer:GetMouse()
p=game.Players.LocalPlayer.Character

g.Button1Down:connect(function(cl)
p.Torso.CFrame=cl.Position
end)
end)
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
23 Feb 2013 07:55 AM
g=game.Players.LocalPlayer:GetMouse()
p=game.Players.LocalPlayer.Character

g.Button1Down:connect(function(cl)
p.Torso.CFrame=cl.hit
end)
end)

Please read output.
Report Abuse
12packkid is not online. 12packkid
Joined: 24 Jun 2011
Total Posts: 1418
23 Feb 2013 07:56 AM
The output I got:
13:55:49.995 - Players.Player1.Backpack.Teleport.LocalScript:7: attempt to index local 'cl' (a nil value)
13:55:49.996 - Script "Players.Player1.Backpack.Teleport.LocalScript", Line 7
13:55:49.996 - stack end
13:55:49.999 - Disconnected event because of exception

The script I used:

script.Parent.Selected:connect(function(mouse)

g=game.Players.LocalPlayer:GetMouse()
p=game.Players.LocalPlayer.Character

mouse.Button1Down:connect(function(cl)
p.Torso.CFrame=cl.Position
end)
end)
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
23 Feb 2013 07:57 AM
A wait yes, Button1Click doesnt pass on any variables. Use the mouse itself.

(A tip: use normal variable names... This will get you confused when the script get bigger.)

g=game.Players.LocalPlayer:GetMouse()
p=game.Players.LocalPlayer.Character

g.Button1Down:connect(function()
p.Torso.CFrame = g.hit
end)
end)
Report Abuse
12packkid is not online. 12packkid
Joined: 24 Jun 2011
Total Posts: 1418
23 Feb 2013 07:58 AM
Now I'm getting the error 'Attempt to index 'cl' nil value'.
I used jobro's script.
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
23 Feb 2013 07:58 AM
g=game.Players.LocalPlayer:GetMouse()
p=game.Players.LocalPlayer.Character

g.Button1Down:connect(function(cl)
p.Torso.CFrame=cl.Position
end)

An end too much.
Report Abuse
zars15 is not online. zars15
Joined: 10 Nov 2008
Total Posts: 9999
23 Feb 2013 07:58 AM
Read wiki.
Report Abuse
12packkid is not online. 12packkid
Joined: 24 Jun 2011
Total Posts: 1418
23 Feb 2013 08:00 AM
Oh wait, I used Jobro's improved one, and it worked, but it works even when I unequip the tool as well. This is a problem I need fixing as if it is a VIP tool, any player can click anywhere and get teleported.
Report Abuse
jobro13 is not online. jobro13
Joined: 05 Aug 2009
Total Posts: 2865
23 Feb 2013 08:02 AM
That's because you use player mouse...

Use the hopperbin one (are you using a hopperbin? Yes? Right?)

p=game.Players.LocalPlayer.Character

local HopperBin = script.Parent

HopperBin.Selected:connect(function(Mouse)
Mouse.Button1Down:connect(function()
p.Torso.CFrame=Mouse.hit
end)
end)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image