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
We use cookies to offer you a better experience. By using Roblox.com, you are agreeing to our Privacy and Cookie Policy.
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: New to tools. Slight problem

Previous Thread :: Next Thread 
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
10 Apr 2015 04:11 PM
Okay, so I have this hierarchy:


Tool
-Handle
--LocalScript


In the LocalScript I have this script:

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
local handle = script.Parent

mouse.Move:connect(function()
handle.CFrame = CFrame.new(handle.CFrame.p, mouse.Hit.p)
end)


I end up flying. I think it has to do with the grips on the Tool:

GripForward: -1, 0, 0
GripPos: 0, 0, -1.5
GripRight: 0, 1, 0
GripUp: 0, 0, 1


But I have no idea how to use the grips, I just ripped that off of some free model sword. How do I accomplish this very simple task?
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
10 Apr 2015 04:16 PM
Nope, whenever you move your mouse, it fires that. In your Right Arm, when you hold a tool, there's a weld called RightGrip which attaches the Handle to your Right Arm. You are setting the CFrame of the Handle so then you are also moving yourself.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
10 Apr 2015 04:17 PM
@rayk How do I fix it then..?
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
10 Apr 2015 04:19 PM
Well, what are you trying to accomplish with the tool?
Report Abuse
Funse is not online. Funse
Joined: 11 Jun 2012
Total Posts: 7887
10 Apr 2015 04:19 PM
lmao
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
10 Apr 2015 04:22 PM
@rayk Don't the code seem obvious enough? I want it to look where my mouse looked lol.
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
10 Apr 2015 04:26 PM
I think that this is correct. It might not be oriented correctly but pretty sure it makes it move

tool.Grip = CFrame.new(hande.CFrame.p, mouse.Hit.p)
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
10 Apr 2015 04:31 PM
That... Failed so badly rayk.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
10 Apr 2015 04:49 PM
http://www.roblox.com/games/236448517&autoplay=True


That's what your script did rayk.

Can anybody help me?
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
10 Apr 2015 04:50 PM
http://www.roblox.com/games/236448517?autoplay=True

THAT'S what your script did rayk LOL

Bump.
Report Abuse
Hibobb is not online. Hibobb
Joined: 18 Apr 2010
Total Posts: 2146
10 Apr 2015 04:51 PM
Try, tool.Grip = CFrame.new(tool.Grip.p,mouse.Hit.p)

Im not completely sure if the tool grip has a C0 and C1 property. If so you will most likely have to edit this since tool.Grip.p would not exist. It would be tool.Grip.C1.p

Alpha release of my game. Send me any bugs you find with the gun. http://www.roblox.com/games/200667607/Sniper-Stuff-ALPHA
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
10 Apr 2015 04:57 PM
Oh I think I understand what I did...

Try this?

tool.Grip = tool.Grip * CFrame.Angles(CFrame.new(handle.CFrame.p, mouse.Hit.p):toEulerAnglesXYZ())
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
10 Apr 2015 04:58 PM
wait nononono, it'll do something, but probably not what you want
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
10 Apr 2015 05:00 PM
@Hibobb Updated game has your script.

It's still nto working properly, for one, the tool doesn't go up and down if you move the mouse up and down, secondly, the tool still doesn't look properly.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
10 Apr 2015 05:02 PM
@rayk That was terrible lol. I couldn't see my tool so I checked the properties of Handle:

Position: nan, nan, nan
Rotation: nan, 90, 0
Velocity: nan, nan, nan

idk how you got all those not a numbers lol.
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
10 Apr 2015 05:06 PM
idk maybe this?

local cf = CFrame.new(handle.CFrame.p, mouse.Hit.p)

local cf = cf - cf.p

tool.Grip = cf
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
10 Apr 2015 05:07 PM
I forgot to not use :toEulerAnglesXYZ cause it sux at rounding
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
10 Apr 2015 05:17 PM
rayk

Extremely close, yours is actually working best at this point. Go to the link I posted earlier to see what it's currently doing (Use the one I posted the 2nd time, the 1st one was broken)
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
10 Apr 2015 05:29 PM
Can I just cheat and cframe the torso to face the mouse?
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
10 Apr 2015 06:06 PM
Lol no, that ruins the whole thing.
Report Abuse
Funse is not online. Funse
Joined: 11 Jun 2012
Total Posts: 7887
10 Apr 2015 06:08 PM
lookVector is there for a reason
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
10 Apr 2015 06:11 PM


Going to rewrite your code

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local torso = char:FindFirstChild("Torso")
local mouse = plr:GetMouse()
local handle = script.Parent

mouse.Move:connect(function()
local cf = CFrame.new(torso.CFrame.p, mouse.Hit.p) * CFrame.Angles(math.pi, math.pi, math.pi)

local cf = cf - cf.p

tool.Grip = cf
end)

I changed it to the torso, cause I thought it looked better by aiming relative to torso. On the game, it seemed like all the directions were inverted by 180 degrees or pi radians. Tried to undo that inverse
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
10 Apr 2015 06:12 PM
@Funse, he wants the tool to change grips to aim at a particular point. I could use lookvector and the law of cosines but too complicated
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
10 Apr 2015 06:15 PM
"Players.Player.Backpack.Tool.Handle.LocalScript:12: attempt to index global 'tool' (a nil value)"

GG, I fixed it doe..


Published the new version. Still not working?
Someone please help!
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
10 Apr 2015 06:24 PM
alright, I looked in the local console, and it says some stuff about the torso. Just change that line in the event to handle.CFrame.p, not torso.CFrame.p
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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