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
 

Re: CFrame.. the struggle..

Previous Thread :: Next Thread 
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
04 Jan 2015 03:03 AM
So i'm trying to make a telekinesis tool, it uses BodyPosition to move the selected part around.. and it works but there's a problem. I have a conditional statement, where if the mouse's hit position is further away from the specified limit then the position shouldn't go any further away. Now the strangest this is that that bit works, but with the conditional then after it goes past the limit, the position automatically makes the X axis 0 for some unknown reason. I want to know how I can make the new position match up with the mouse's X axis, but still have the Z axis limit. Any ideas? Here's the bit of code for moving the part, all variables are defined and DistanceLimit is 100.

This is a localscript.

Move = (function (Mouse, Obj)
local BodyPosition, CharTorso = Instance.new("BodyPosition",Obj), Plyr.Character.Torso;
BodyPosition.maxForce = Vector3.new(Obj.Size.X*5000,Obj.Size.Y*5000,Obj.Size.Z*5000)
MovingObject = true
while MovingObject do
local mouseHit = Mouse.Hit.p
--[[CONDITIONAL IS HERE]]--
if (mouseHit - CharTorso.CFrame.p).magnitude <= DistanceLimit then
pos = CFrame.new(mouseHit.X,5,mouseHit.Z)
else
--[[THIS IS WHAT'S MESSED UP]]--
pos = (CFrame.new(mouseHit.X,5,0) + Vector3.new(CharTorso.CFrame * CFrame.new(0,0,DistanceLimit)))
-------------------------------------------
end
BodyPosition.position = (pos).p
wait(0.1)
end
MovingObject = false
BodyPosition:Destroy()
end)
Report Abuse
Raybon is not online. Raybon
Joined: 19 Jul 2011
Total Posts: 38
04 Jan 2015 03:07 AM
Consider this a bump and a bit of a suggestion, I'm extremely new to scripting, so I really shouldn't be posting on posts like these, xD

When the "This is what is messed up" code resets the # values, does it break the script?
Report Abuse
Raybon is not online. Raybon
Joined: 19 Jul 2011
Total Posts: 38
04 Jan 2015 03:09 AM
Yeah, I have a garbage theory, and it really won't help you, but I think DistanceLimit doesn't allow you to go any further (of course) so it turns the values to 0 because there is nothing defining it further?

Anyone reading this, don't bother making fun of me :D I'm already doing so myself..
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
04 Jan 2015 03:32 AM
bump, cntkillme chur test 4 novice scripter.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
04 Jan 2015 03:48 AM
'pos = (CFrame.new(mouseHit.X,5,0) + Vector3.new(CharTorso.CFrame * CFrame.new(0,0,DistanceLimit)))'

CFrame in a Vector3 wat :))

Well for 1 you setting z to 0 '(mouseHit.X,5,0)' and trying to add some weird vector thing to it. And you want to constraint it from all axes, not only z.
So maybe something like

_, pos = workspace:FindPartOnRay(
Ray.new(torso.Position, (Vector3.new(mouseHit.X, 5, mouseHit.Z) - torso.Position).unit * DistanceLimit),
character
);

So if it's passed the DistanceLimit, you set it to the "edge" of your circle. You might need to change that a bit but blah
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
04 Jan 2015 03:57 AM
Z isn't the problem, X is. I'm setting Z to 0 then adding Vector3 stuffs, and it works fine. But x always gets set to 0 :(
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
04 Jan 2015 04:00 AM
Z and X are both horizontal. You don't want someone to be able to go past their limit just because they are facing a different direction.
Also what are you trying to do here:

'Vector3.new(CharTorso.CFrame * CFrame.new(0,0,DistanceLimit)))'
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
04 Jan 2015 04:01 AM
By passed the limit, I mean incorrectly placed :) Not necessarily passed the limit.
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
04 Jan 2015 04:06 AM
This is what I think you mean:
prntscr/5obafx

If they go passed the limit, it will place is at the limit.
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
04 Jan 2015 09:09 AM
Yesssssss. So are you saying I have to make the x and z axis relative to the player but extended by the distancelimit? O::
Report Abuse
DeviousDeviation is not online. DeviousDeviation
Joined: 28 Dec 2010
Total Posts: 9306
04 Jan 2015 09:15 AM
i made this a while ago, dunno if I saved the code

logic is logical
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
04 Jan 2015 10:06 AM
Nevermind, I fixed it:P
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
04 Jan 2015 01:06 PM
Did you do this which for some reason didn't think about

CFrame.new(torso.Position, Vector3.new(mouseHit.X, 5, mouseHit.Z)) * CFrame.new(0, 0, -Dist)
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
04 Jan 2015 01:20 PM
Pretty close, yes.

pos = (CFrame.new(CharTorso.Position,mouseHit) * CFrame.new(0,5,-DistanceLimit))
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
05 Jan 2015 08:52 PM
Award me for being good at something for once cnt..
Report Abuse
cntkillme is not online. cntkillme
Joined: 07 Apr 2008
Total Posts: 44956
05 Jan 2015 09:04 PM
No, anti-IE ppl suck :))
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
05 Jan 2015 09:12 PM
w0t about a cookie :))
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