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: Weld

Previous Thread :: Next Thread 
Maro445 is not online. Maro445
Joined: 27 Aug 2012
Total Posts: 14
07 Apr 2015 08:43 PM
I made a script which welds a part to my torso.

Now i want to make it rotate but when i use weld.C1 = weld.C1 * CFrame.Angles(0,0,0.1)
This just behaves the same way like CFrame.new(0,0,0.1)

Anyhelp on how to rotate a welded part ?






Thanks.
Report Abuse
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
07 Apr 2015 08:45 PM
weld.C1 = --Rotation

i.e

weld.C1 = CFrame.fromAxisAngle(Vector3.new(.707, 0, .707), math.pi/2)

Report Abuse
JimmyChance is not online. JimmyChance
Joined: 01 Nov 2009
Total Posts: 3681
07 Apr 2015 08:46 PM
what is your C0 and C1 by the way (if set)?
Report Abuse
Maro445 is not online. Maro445
Joined: 27 Aug 2012
Total Posts: 14
07 Apr 2015 08:54 PM
Well i set it weld.C0 = Torso.CFrame:inverse() and weld.C1 = Part.CFrame:inverse()
When i use the math.pi thing it doesn't rotate right it rotates a little bit and moves far away from it's position.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
07 Apr 2015 09:08 PM
Why do you have them set to the inverses of CFrames? Do you even know why you set them to that?

Is it because you've seen it done like that before?
Report Abuse
Maro445 is not online. Maro445
Joined: 27 Aug 2012
Total Posts: 14
07 Apr 2015 09:16 PM
No i've just learned it like that xD so can you tell me what i'm supposed to do please?
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
07 Apr 2015 09:21 PM
Yeah, just explain to me moreover what you want it to do. It's important not to use code you've only seen and don't understand. If you've seen it and understand it, then by all means use it.

Do you want to weld a part to your torso and keep the part where it was originally at, or do you just want it to literally be connected to your torso?

We'll start there and then I can show you how to do whatever else you want.
Report Abuse
Maro445 is not online. Maro445
Joined: 27 Aug 2012
Total Posts: 14
07 Apr 2015 09:33 PM
Well i want it to be a tail welded to my torso


and ofcourse make it rotate and move and stuff like that i had no problem making it move but the problem is about rotating but if explaining it all over will help fix the problem then please do
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
07 Apr 2015 09:45 PM
Ah, I see. Let's try this out then. You're actually going to want to rotate the C0, but you will need to use both C0 and C1 for this sort of thing.

Here's an example of how you might do this:

local TestPlayer = Game.Players:WaitForChild("Player1");
local Character = TestPlayer.Character or TestPlayer.CharacterAdded:wait();

local Part = Instance.new("Part", workspace);

local Weld = Instance.new("Weld", Part);
Weld.Part0 = TestPlayer.Character:WaitForChild("Torso");
Weld.Part1 = Part;
Weld.C0 = CFrame.new(0,-1,-1)
Weld.C1 = CFrame.new(-3,-.5,0) * CFrame.fromAxisAngle(Vector3.new(0,1,0), math.pi/2) * CFrame.fromAxisAngle(Vector3.new(-1,0,0), math.pi/3.25)

-- Rotation
while wait() do
for i = 0, 45 do
Weld.C0 = Weld.C0 * CFrame.Angles(0,math.rad(1),0)
wait()
end
for i = 0, 90 do
Weld.C0 = Weld.C0 * CFrame.Angles(0,math.rad(-1),0)
wait()
end
for i = 0, 45 do
Weld.C0 = Weld.C0 * CFrame.Angles(0,math.rad(1),0)
wait()
end
end

To test how that works, just put it in the workspace and join the game.
Report Abuse
Maro445 is not online. Maro445
Joined: 27 Aug 2012
Total Posts: 14
07 Apr 2015 09:52 PM
One thing i don't get is why have you set the C0 and C1 to new values i thought they're supposed to be set to the values of the CFrames of Part1 and Part0
Report Abuse
Maro445 is not online. Maro445
Joined: 27 Aug 2012
Total Posts: 14
07 Apr 2015 09:54 PM
and also didn't work but doesn't give any errors.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
07 Apr 2015 10:00 PM
It works for me. You're probably testing it wrong. The best way to do it is join the game first (this is in Studio test mode) so your player is named Player1.

Then insert the script, paste the code I gave you, then click the Disabled check box of the script in the properties window two times (to check and then uncheck it) and it will attach a part to your tail area and make it move.
Report Abuse
Maro445 is not online. Maro445
Joined: 27 Aug 2012
Total Posts: 14
07 Apr 2015 10:07 PM
Oh i tried it in play solo my bad okay and about why you put different values in C0 and C1 can you plesae tell me?
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
07 Apr 2015 10:15 PM
C0 is the location where the two parts will be joined in offset from Part0's CFrame. For example, if you put CFrame.new(0,1,0) in C0 then Part1 will be placed 1 stud above the Part0's CFrame (and it respects rotation, meaning it will be 1 stud above the TOP surface of Part0).

C1 will adjust Part1 even more. However, it will adjust it from Part0.CFrame * C0 instead of just Part0's CFrame.

I use C0 to position where I connect the two parts, and I use C1 to make Part1 angled the way it is. C0 is used to adjust the CFrame where they are joined so it will animate the tail without changing the way the tail is rotated.
Report Abuse
Maro445 is not online. Maro445
Joined: 27 Aug 2012
Total Posts: 14
07 Apr 2015 10:18 PM
It worked but i don't understand why did you set the c0 and c1 to these values if you're still coming to the post please answer cuz i need to know so i can make the scripts myself and also math.rad(1) what does that mean and how can i use that to control the rotation and is 1 and -1 the only values that can be used or i can make it what ever , alot of questions i have. sorry if i'm annoying i'm just trying to learn
Report Abuse
Maro445 is not online. Maro445
Joined: 27 Aug 2012
Total Posts: 14
07 Apr 2015 10:21 PM
oops posted that too soon but ya thanks alot i understood what's c1 and c0 are for now only thing i'm not really sure about are the math.rad and stuff like that if there is something specially for it like a page on wiki or something that would be great cuz the lsat time i searched up the wiki for welding it didn't say anything about math.rad it only said about math.pi which was a great failure with me
Report Abuse
Maro445 is not online. Maro445
Joined: 27 Aug 2012
Total Posts: 14
07 Apr 2015 10:22 PM
Please if you know anywhere i can increase my knowledge of lua so i can make more advanced scripts and understand what i don't, please that would be great if you link me it.
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
07 Apr 2015 10:23 PM
It is based on "radians."

Instead of degrees. I use radians.
Report Abuse
Maro445 is not online. Maro445
Joined: 27 Aug 2012
Total Posts: 14
07 Apr 2015 10:28 PM
Oh so it's possible to use degrees?
Report Abuse
MrNicNac is not online. MrNicNac
Joined: 29 Aug 2008
Total Posts: 26567
07 Apr 2015 10:29 PM
I did use degrees.

math.rad() turns a degree into a radian. ROBLOX's CFrame functions use radians for rotation. So I turned 1 degree into a radian.
Report Abuse
Maro445 is not online. Maro445
Joined: 27 Aug 2012
Total Posts: 14
07 Apr 2015 10:36 PM
Oh i see so for example if i connect the tail to the mouse movement and make it if the mouse moves right the tail moves and rotates to the right direction and that way i'll achieve what i've been trying to figure out for like 2 weeks now e.e Thanks you've been a great help i'm very grateful to you right now thanks alot you just saved my life i almost had given up on doing it
Report Abuse
Maro445 is not online. Maro445
Joined: 27 Aug 2012
Total Posts: 14
07 Apr 2015 10:37 PM
I would also appreciate it if there is a place other than the wiki that i could increase my lua knowledge through , please if you know link me it.
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