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: I need help with welding and cframe.

Previous Thread :: Next Thread 
fleetcom is not online. fleetcom
Joined: 07 Jul 2009
Total Posts: 15546
21 Sep 2015 12:20 PM
I found some old auto turrets in my computer's files from that old 2012 ROBLOX battleship game and I wanted to use them on some vehicles like my Land Raider.

Problem is when the turret is welded and unachored, whenever it turns to its target it turns the entire vehicle to turn and I honestly don't know very much about welding and cframe to fix this myself and it's probably really easy so it makes me feel even more like a tard lol.

How would I fix this exactly? If you're up to giving me a solution I can give you the model, not like it's really my scripting anyways lol.
Report Abuse
fleetcom is not online. fleetcom
Joined: 07 Jul 2009
Total Posts: 15546
21 Sep 2015 12:21 PM
***it moves the entire vehicle instead of the just the turret.
Report Abuse
fleetcom is not online. fleetcom
Joined: 07 Jul 2009
Total Posts: 15546
21 Sep 2015 12:25 PM
also forgot if you do help thanks and sorry lol.
Report Abuse
fleetcom is not online. fleetcom
Joined: 07 Jul 2009
Total Posts: 15546
21 Sep 2015 12:52 PM
last time ill bump this so im not being annoying
Report Abuse
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
21 Sep 2015 12:56 PM
How 'bout welding all the parts in the vehicle to one part, welding all the parts in the turret to one part, and then editing the CFrame of the weld connecting those two parts to rotate the turret?


--ThatChristianGuy
Report Abuse
fleetcom is not online. fleetcom
Joined: 07 Jul 2009
Total Posts: 15546
21 Sep 2015 12:59 PM
Well I think I have the parts welded to one part in the vehicle, because I have the turret model then a weld script that welds them to a primary part that's inside the separate vehicle model.

But I don't exactly know how to edit the CFrame of the weld so it rotates the turret rather than the whole vehicle.
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
21 Sep 2015 01:00 PM
First you need to explain how it moves in the first place. My theory is that it is moved by adjusting the weld property C0 or C1. Then, some other parts are, in turn, welded to the turret (meaning it is welded incorrectly in the first place) and causing everything to move with it.
Report Abuse
fleetcom is not online. fleetcom
Joined: 07 Jul 2009
Total Posts: 15546
21 Sep 2015 01:03 PM
This is what I believe allows the turret the turn, which is what I believe I need to edit or change the way it makes the part(s) turn.

function lookat(pivotpoint,pos)
local gun=sp:FindFirstChild("Gun")
local stand=sp:FindFirstChild("MainPart")
gun.CFrame=CFrame.new(pivotpoint,pos)*CFrame.new(0,.5,-1.6)
end
Report Abuse
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
21 Sep 2015 01:04 PM
That edits the CFrame of a part in the turret itself, which in turn moves everything it's connected to. Hence, the whole vehicle.


--ThatChristianGuy
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
21 Sep 2015 01:05 PM
Mphm. That doesn't look like a very good way to turn it - it'll probably rotate anything connected to it.

Can you show me where the weld for the turret is created. Is it scripted, or is it via a weld surface?
Report Abuse
fleetcom is not online. fleetcom
Joined: 07 Jul 2009
Total Posts: 15546
21 Sep 2015 01:07 PM
This is what creates the weld with the turret parts and a vehicle part:

weld=(function(x,y,s)
w=Instance.new("Weld")
w.Part0=x
w.Part1=y
w.C0=x.CFrame:inverse()
w.C1=y.CFrame:inverse()
if s~=nil then
w.Name=s
end
w.Parent=x
end)

weldAll=(function(mainpart)
f=script.Parent:GetChildren()
for i=1,#f do
if f[i]:IsA("Part") or f[i]:IsA("WedgePart") or f[i]:IsA("CornerWedgePart") then
weld(mainpart,f[i])
end
end
for i=1,#f do
if f[i]:IsA("Part") or f[i]:IsA("WedgePart") or f[i]:IsA("CornerWedgePart") then
f[i].Anchored=false
end
end
end)

weldAll(script.Parent.MainPart)
weld(script.Parent.Parent.Vehicle.MainPart2,script.Parent.MainPart,"TURRETWELD")

tw=script.Parent.Parent.Vehicle.MainPart2.TURRETWELD
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
21 Sep 2015 01:09 PM
That's some awful looking code. Is the turret multiple parts? Because that will make things a lot more difficult.
Report Abuse
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
21 Sep 2015 01:10 PM
Wouldn't really make it that much more difficult.


--ThatChristianGuy
Report Abuse
nox7 is not online. nox7
Joined: 29 Aug 2008
Total Posts: 27467
21 Sep 2015 01:11 PM
"Wouldn't really make it that much more difficult."

I think so. Because all the parts are being welded to one main part. If all the parts of the turret are welded somewhere else, you'd need to deal with that one of two ways.

1) Figure out which parts belong to the turret, and weld them to a main turret part.
2) Move all the parts using the C1 to face the target
Report Abuse
fleetcom is not online. fleetcom
Joined: 07 Jul 2009
Total Posts: 15546
21 Sep 2015 01:17 PM
It's only 3 parts.
Report Abuse
fleetcom is not online. fleetcom
Joined: 07 Jul 2009
Total Posts: 15546
21 Sep 2015 01:18 PM
Which only really two parts in the turret are important, the third is mainly to increase the model size so it has a hitbox.

The only two important parts are the Mainpart which the turret swivels on and the Gun which is the turret mesh.
Report Abuse
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
21 Sep 2015 01:18 PM
He could just get the turret parts grouped in a model, then the script doesn't have a ton of work to do.

Also here:

weld = function(x, y, s)
local newWeld = Instance.new("Weld")
newWeld.Part0 = x
newWeld.Part1 = y
newWeld.C0=x.CFrame:inverse()
newWeld.C1=y.CFrame:inverse()
newWeld.Name = s or 'Weld'
newWeld.Parent = x
end

weldAll = function(mainpart, bin)
for _, Part in pairs(bin:GetChildren()) do
if Part:IsA("BasePart") then
weld(mainpart, Part)
Part.Anchored = false
end
end
end

weldAll(script.Parent.MainPart, script.Parent)
weld(script.Parent.Parent.Vehicle.MainPart2,script.Parent.MainPart,"TURRETWELD")

tw = script.Parent.Parent.Vehicle.MainPart2.TURRETWELD


--ThatChristianGuy
Report Abuse
fleetcom is not online. fleetcom
Joined: 07 Jul 2009
Total Posts: 15546
21 Sep 2015 01:19 PM
**MainPart
Report Abuse
fleetcom is not online. fleetcom
Joined: 07 Jul 2009
Total Posts: 15546
21 Sep 2015 01:20 PM
Thanks!

Now what exactly would I have to do to fix the problem with the turret movement?
Report Abuse
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
21 Sep 2015 01:25 PM
First put the vehicle in a model, the turret in a model, and both of those in a model, then give us the hierarchy.


--ThatChristianGuy
Report Abuse
fleetcom is not online. fleetcom
Joined: 07 Jul 2009
Total Posts: 15546
21 Sep 2015 01:27 PM
Tank
Turret1
Turret2
Body

that what you mean?
Report Abuse
fleetcom is not online. fleetcom
Joined: 07 Jul 2009
Total Posts: 15546
21 Sep 2015 01:33 PM
If you want I could just give you the model.
Report Abuse
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
21 Sep 2015 01:39 PM
Ye. There should be like a base for each turret in the tank model too. What are the names for the turrets? I don't want your model because that would require opening studio.


--ThatChristianGuy
Report Abuse
fleetcom is not online. fleetcom
Joined: 07 Jul 2009
Total Posts: 15546
21 Sep 2015 01:43 PM
Turret1 and Turret2

In the vehicle body there's MainPart1/MainPart2 which are the parts each turret connects to if that helps.
Report Abuse
ThatChristianGuy is not online. ThatChristianGuy
Joined: 14 Jun 2014
Total Posts: 1283
21 Sep 2015 01:56 PM
Sorry... I meant but didn't communicate clearly that I wanted to know the names of the actual turret parts in the turret models. Because you said there was a part that was the turret and a hitbox part in each turret model.


--ThatChristianGuy
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