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 » Scripters
Home Search
 

Tool follow cursor

Previous Thread :: Next Thread 
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
11 Apr 2015 11:57 AM
Kapitanovas made this script for me, he claims there's some sort of roblox glitch stopping it from working properly. Can anyone verify that this is his fault and/or provide a solution?

local plr = game.Players.LocalPlayer
local char = plr.Character or plr.CharacterAdded:wait()
local mouse = plr:GetMouse()
local can = false
repeat wait() until char
local rarm = char:WaitForChild('Right Arm')

function equipped()
can = true
end

function weld()
if can then
local w1 = rarm:FindFirstChild('RightGrip')

if w1 then
local point = (mouse.Hit.p - script.Parent.Handle.Position).unit
w1.C0, w1.C1 = CFrame.new(0, -2, 0), CFrame.new() * CFrame.Angles(-point.X, -point.Y, -point.Z)
--print(w1.C1)
end
end
wait()
end

function unequipped()
can = false
end

mouse.Move:connect(weld)
script.Parent.Equipped:connect(equipped)
script.Parent.Unequipped:connect(unequipped)
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
11 Apr 2015 12:00 PM
as I said, wen Equipping a Tool, for some Reason it gives off a CFrame/Position that's not what it was when Developing... so for example, I tried making a Weld Script (The Usual) for my Friend that's kinda New to Developing and stuff, and so the Parts of the Gun were all over the Map! (There were 2 Parts) nothing Worked!

"My Life is going Good... but..."
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
11 Apr 2015 12:02 PM
@Kap

Your example is invalid, that's a scripting problem that you can fix with CFrameValues and such. It has nothing to do with this
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
11 Apr 2015 12:04 PM
@Kap reinvite me to the party lol, I DCd
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
11 Apr 2015 12:05 PM
em, do u even Weld or anything??? o.O
clearly not...
I was Developing a FEW Times and the same thing happened, only thing I could do is Record the Differences in Position between the Parts and use those for the Weld Offsets... cos I'm not talking about Joints, am talking about this dude:
(mouse.Hit.p - Handle.Position).unit
cos if the Handle.Position is messed up then wat u expect? -_-

"My Life is going Good... but..."
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
11 Apr 2015 12:05 PM
it's Max thats the Leader XD
btw, isnt ur Settings set to 'Not take Party Invites'?

"My Life is going Good... but..."
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
11 Apr 2015 12:08 PM
That is because Kapitanovas' code is completely wrong.

This will do exactly what you want:

if w1 then
w1.C0 = CFrame.new(0, -2, 0)
w1.C1 = (CFrame.new((w1.Part0.CFrame * w1.C0).p, mouse.Hit.p)):toObjectSpace(w1.C0 * rarm.CFrame);
--print(w1.C1)
end
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
11 Apr 2015 12:08 PM
Please no CFrame war, I need the script fixed XD
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
11 Apr 2015 12:10 PM
"Please no CFrame war, I need the script fixed XD"

Give that code a go. There's no war. Mine just works :)
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
11 Apr 2015 12:11 PM
@MirNicNac It works! 1 slight problem, while using it the tool is not longer held in your hand.

Also, do me a favor and explain to Kap why his code don't work. He's stuck on the idea it's roblox's fault lol.
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
11 Apr 2015 12:12 PM
@war

You can fix the position of the tool by messing with the Grip
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
11 Apr 2015 12:12 PM
MrNic, em, I have experience with my Code :P
I know wat am doing...
it's just the Fact that, as I said
(mouse.Hit.p - Handle.Position).unit
is giving me Wrong Units...
try Welding a Gun or something with their Default CFrames :P

"My Life is going Good... but..."
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
11 Apr 2015 12:14 PM
@Kaptinovas

Your math is completely wrong for this kind of thing, sorry. You might understand your code, but you're not using it right.

You need to know that joints work in object-space (relative) units. Your direction code (mouse-handle).unit was working fine - you just never turned it into object-space units.

@warspyking

One second, I'll fix that. It's because of the C0 * Part0.CFrame is being inverted.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
11 Apr 2015 12:17 PM
@rayk Explain, I'm modifying the properties in edit but it won't work when I use the tool?
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
11 Apr 2015 12:17 PM
@warspyking

Here's the fix:

if w1 then
w1.C0 = CFrame.new(0, -2, 0)
w1.C1 = (CFrame.new((rarm.CFrame).p, mouse.Hit.p)):toObjectSpace(rarm.CFrame);
end

I just stopped composition the C0 matrix into the relation.
Report Abuse
rayk999 is not online. rayk999
Joined: 18 Feb 2011
Total Posts: 4705
11 Apr 2015 12:20 PM
Just use MrNicNac's code. But the Grip is the position and rotation of the Handle relative to the right arm
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
11 Apr 2015 12:20 PM
"Just use MrNicNac's code. But the Grip is the position and rotation of the Handle relative to the right arm"

In this case, the Grip properties will _not_ do anything. The Grip is actually the C1 matrix split up into four Vector3s. We are manually editing the C1, so we are overriding the Grip properties.
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
11 Apr 2015 12:21 PM
wait just a sec...
hmmm... makes sense a lil cos... I only did 1 Axis at a Time wen I used that kinda of thing
(mouse - part)
so it might just be the Global thing for the X & Z Axises that didnt Work out... but I'm also pretty sure that if u at least define the Parts in the Tool and then use those Variables then the Positions will go like crap :/ try it...

but so lemme see... :toObjectSpace(myUnit)?

"My Life is going Good... but..."
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
11 Apr 2015 12:24 PM
@Kapitanovas

You also used CFrame.Angles and gave it vector points and not actual angles..

Like what
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
11 Apr 2015 12:26 PM
wait just a sec... am confused... tell me in more detail?

"My Life is going Good... but..."
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
11 Apr 2015 12:28 PM
You got a direction

(mouse-handle).unit

From the handle in the direction of the mouse. Then you gave that direction to CFrame.Angles

CFrame.Angles(pointX, ...)

That makes 0 sense. Why would you give a vector direction to a function which expects Euler angles. That would never have worked.
Report Abuse
warspyking is not online. warspyking
Joined: 15 Nov 2011
Total Posts: 13947
11 Apr 2015 12:35 PM
ty MrNicNac


@MrNicNac, How can I keep the tool attached my it's end? (Play my game Tools Testing to see what I mean)
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
11 Apr 2015 12:36 PM
it worked before XD

"My Life is going Good... but..."
Report Abuse
Kapitanovas is not online. Kapitanovas
Joined: 09 Sep 2012
Total Posts: 4216
11 Apr 2015 12:45 PM
btw, MrNic, if u mean I should have done
math.rad() then that wouldn't Work :P

"My Life is going Good... but..."
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
11 Apr 2015 01:06 PM
"btw, MrNic, if u mean I should have done
math.rad() then that wouldn't Work :P"

I give up. You obviously do not understand.

"@MrNicNac, How can I keep the tool attached my it's end? (Play my game Tools Testing to see what I mean)"

if w1 then
w1.C0 = CFrame.new(0, -2, 0)
w1.C1 = (CFrame.new((rarm.CFrame).p, mouse.Hit.p) + (w1.Part1.CFrame:vectorToWorldSpace(Vector3.new(0,0,-w1.Part1.Size.Z/2)))):toObjectSpace(rarm.CFrame);
end
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 2Go to page: [1], 2 Next
 
 
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