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: Grabbing the Mouse

Previous Thread :: Next Thread 
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
24 Jul 2012 04:30 PM
function onEquip(Mouse)
Gyro = Instance.new("BodyGyro",game.Players.LocalPlayer.Character.Torso)
Gyro.maxTorque = Vector3.new(0,9.0000e+009,0)

-- THIS EVENT DOESN"T FIRE!?

Mouse.Move:connect(function()
Gyro.cframe = Mouse.Hit
end)

script.Parent = game.Players.LocalPlayer.Character
game.Players.LocalPlayer.Character.Tool:Destroy()
end

script.Parent.Equipped:connect(onEquip)

while game.Players.LocalPlayer.Character == nil do
wait(0.1)
end
while game.Players.LocalPlayer.Character:FindFirstChild("Torso") == nil do
wait(0.1)
end

script.Parent.Parent = game.Players.LocalPlayer.Character
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
24 Jul 2012 06:03 PM
I yelp for help.
Report Abuse
thedeathmaster01 is not online. thedeathmaster01
Joined: 14 Mar 2010
Total Posts: 6331
24 Jul 2012 06:06 PM
Add a few prints around the script to confirm what is working and what's not
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
24 Jul 2012 06:27 PM
I already did.


Mouse.Move:connect(function()
Gyro.cframe = Mouse.Hit
end)

THIS isn't working.
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
24 Jul 2012 06:29 PM
CFrame
Report Abuse
CeaselessSoul is not online. CeaselessSoul
Joined: 03 Jul 2012
Total Posts: 7506
24 Jul 2012 06:29 PM
Oops, sorry never mind.
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
24 Jul 2012 09:32 PM
The mouse exists, but its events don't fire?
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
24 Jul 2012 09:56 PM
•~-=[○◘/☼\◘○]=-~•
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
24 Jul 2012 10:05 PM
○=•-◘> ¿ <◘-•=○
Report Abuse
dirk29 is not online. dirk29
Joined: 26 May 2010
Total Posts: 1142
24 Jul 2012 10:07 PM
Maybe Mouse.hit.Position? I don't use the mouse very often.
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
24 Jul 2012 10:16 PM
It's not the function that's the problem, it's fact that event won't fire!
Report Abuse
builderman1171 is not online. builderman1171
Joined: 27 Mar 2010
Total Posts: 1595
24 Jul 2012 10:25 PM
Try

Gyro.cframe = Mouse.Hit.p

or

Gyro.cframe = Mouse.Hit.CFrame --might need to change that to 'cframe'.


--TehChikenHater ლ(ಠ_ಠლ)
Report Abuse
builderman1171 is not online. builderman1171
Joined: 27 Mar 2010
Total Posts: 1595
24 Jul 2012 10:27 PM
The problem isn't your function. Nothing is generating an error, your just doing it wrong. Mouse.Hit isn't what you need, as I said above, use Mouse.Hit.p, or Mouse.Hit.CFrame/cframe. I don't use Mouse a whole lot, but I know enough to tell you that you are, in fact, doing it wrong. I blame John personally.

--TehChikenHater ლ(ಠ_ಠლ)
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
24 Jul 2012 10:37 PM
Yes, I know, but when I tested the function with print statements, the event never fired. -_-
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
24 Jul 2012 10:41 PM
Well, you can't exactly define a CFrame with a part.
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
24 Jul 2012 11:05 PM
Well, I cleaned up the code. It works a bit better now, but there's only one problem: The event will fire a few times, but will eventually halt altogether?

local Tool = Instance.new("Tool")

local Handle = Instance.new("Part",Tool)
Handle.Name = "Handle"
Handle.Transparency = 1

Tool.Equipped:connect(function(Mouse)
Tool.Parent = nil
local Gyro = Instance.new("BodyGyro",game.Players.LocalPlayer.Character.Torso)
Gyro.maxTorque = Vector3.new(0,math.huge,0)
Mouse.Move:connect(function()
print("Moved")
Gyro.cframe = Mouse.Hit
end)
end)

Tool.Parent = game.Players.LocalPlayer.Character
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
24 Jul 2012 11:48 PM
BUMP

Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
24 Jul 2012 11:50 PM
Again....
How
The
****
Would
You
Define a cframe with an instance?
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
24 Jul 2012 11:52 PM
The 'Hit' property of the mouse IS a CFrame value.
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
24 Jul 2012 11:53 PM
q_q.....
I am ashamed...
Sorry :(
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
24 Jul 2012 11:55 PM
Bah, I just need to get this event working! Any advice?
Report Abuse
mamaguy is not online. mamaguy
Joined: 07 Oct 2010
Total Posts: 7073
24 Jul 2012 11:59 PM
ummm....
Don't use anonymous functions?
They annoy me q.q
Report Abuse
thek00lkid is not online. thek00lkid
Joined: 18 Jun 2011
Total Posts: 2778
25 Jul 2012 09:35 AM
They take up less memory. =3
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
25 Jul 2012 09:44 AM
local Tool = Instance.new("Tool")

local Handle = Instance.new("Part",Tool)
Handle.Name = "Handle"
Handle.Transparency = 1

Tool.Equipped:connect(function(Mouse)
Tool.Parent = nil
local Gyro = Instance.new("BodyGyro",game.Players.LocalPlayer.Character.Torso)
Gyro.maxTorque = Vector3.new(0,math.huge,0)
Mouse.Move:connect(function()
print("Moved")
Gyro.cframe = Mouse.Hit
end)
end)

Tool.Parent = game.Players.LocalPlayer.Character <<<<<<
Why is that at the end??
Report Abuse
citymaster22 is not online. citymaster22
Joined: 10 Jan 2010
Total Posts: 4993
25 Jul 2012 09:48 AM
One more thing. How about you try it without removing the tool?
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