of     1   

Goulstem
#153230123Sunday, January 04, 2015 9:03 AM GMT

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)
Raybon
#153230261Sunday, January 04, 2015 9:07 AM GMT

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?
Raybon
#153230365Sunday, January 04, 2015 9:09 AM GMT

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..
Goulstem
#153231328Sunday, January 04, 2015 9:32 AM GMT

bump, cntkillme chur test 4 novice scripter.
cntkillme
#153232010Sunday, January 04, 2015 9:48 AM GMT

'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
Goulstem
#153232334Sunday, January 04, 2015 9:57 AM GMT

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 :(
cntkillme
#153232481Sunday, January 04, 2015 10:00 AM GMT

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)))'
cntkillme
#153232509Sunday, January 04, 2015 10:01 AM GMT

By passed the limit, I mean incorrectly placed :) Not necessarily passed the limit.
cntkillme
#153232668Sunday, January 04, 2015 10:06 AM GMT

This is what I think you mean: prntscr/5obafx If they go passed the limit, it will place is at the limit.
Goulstem
#153242519Sunday, January 04, 2015 3:09 PM GMT

Yesssssss. So are you saying I have to make the x and z axis relative to the player but extended by the distancelimit? O::
DeviousDeviation
#153242822Sunday, January 04, 2015 3:15 PM GMT

i made this a while ago, dunno if I saved the code logic is logical
Goulstem
#153245271Sunday, January 04, 2015 4:06 PM GMT

Nevermind, I fixed it:P
cntkillme
#153258132Sunday, January 04, 2015 7:06 PM GMT

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)
Goulstem
#153259253Sunday, January 04, 2015 7:20 PM GMT

Pretty close, yes. pos = (CFrame.new(CharTorso.Position,mouseHit) * CFrame.new(0,5,-DistanceLimit))
Goulstem
#153369600Tuesday, January 06, 2015 2:52 AM GMT

Award me for being good at something for once cnt..
cntkillme
#153370561Tuesday, January 06, 2015 3:04 AM GMT

No, anti-IE ppl suck :))
Goulstem
#153371301Tuesday, January 06, 2015 3:12 AM GMT

w0t about a cookie :))

    of     1