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

Previous Thread :: Next Thread 
yobo89 is not online. yobo89
Joined: 05 Jun 2010
Total Posts: 2341
23 Mar 2015 12:16 PM
How can i get a part(a turret) to rotate so the front of it is facing where it is about to shoot its raycast, if you need my raycast script just say
Report Abuse
blooo127127 is not online. blooo127127
Joined: 22 Jul 2010
Total Posts: 403
23 Mar 2015 12:34 PM
That is a complicated piece of work that Im not willing to give out for free. And I give out a lot of stuff.

1: Use BodyGyro

2: Fake the turret. Make it a circle.
Report Abuse
yobo89 is not online. yobo89
Joined: 05 Jun 2010
Total Posts: 2341
23 Mar 2015 12:44 PM
well that wasn't much help, can i not just get the angle from the turret to the ship and point it there?
Report Abuse
DeviousDeviation is not online. DeviousDeviation
Joined: 28 Dec 2010
Total Posts: 9306
23 Mar 2015 12:46 PM
is the turret anchored?

⬡
Report Abuse
yobo89 is not online. yobo89
Joined: 05 Jun 2010
Total Posts: 2341
23 Mar 2015 12:48 PM
No
Report Abuse
chimmihc is not online. chimmihc
Joined: 01 Sep 2014
Total Posts: 17143
23 Mar 2015 12:48 PM
I would recommend not using BodyGyro and learning how to CFrame.


I script -~ chimmihc
Report Abuse
yobo89 is not online. yobo89
Joined: 05 Jun 2010
Total Posts: 2341
23 Mar 2015 12:48 PM
its welded to a
ship
Report Abuse
yobo89 is not online. yobo89
Joined: 05 Jun 2010
Total Posts: 2341
23 Mar 2015 12:49 PM
local Player = game.Players.LocalPlayer
local Character = Player.Character
local Mouse = Player:GetMouse()
local PlayerGui = Player:WaitForChild("PlayerGui")

local MAX_DISTANCE = 200



local rayFromShip = Character:FindFirstChild("HumanCarrier") or Character:FindFirstChild("HumanCorvette") or
Character:FindFirstChild("Cruiser") or Character:FindFirstChild("Spider")

local rayFromPart = rayFromShip:FindFirstChild("Part")

local rayFrom = rayFromPart:FindFirstChild("Turret")


--while wait(1) do
Mouse.KeyDown:connect(function(Key)
if Key == "f" then
local target = nil
local dist = MAX_DISTANCE
for _,v in pairs(game.Workspace:GetChildren()) do
local foundShip = v:FindFirstChild("HumanCarrier") or v:FindFirstChild("HumanCorvette") or
v:FindFirstChild("Cruiser") or v:FindFirstChild("Spider")
if foundShip ~= nil and foundShip ~= rayFromShip then

local mag = (rayFrom.Position - foundShip.Position).magnitude
if mag < dist then
target = foundShip
dist = mag
end
end
end
if target ~= nil then
local magnitude = (rayFrom.Position - target.Position)
local ray = Ray.new(rayFrom.Position, (target.Position - rayFrom.Position))
local hit, position = game.Workspace:FindPartOnRay(ray, rayFrom)
local humanoid = hit:FindFirstChild("Health")
if humanoid then
if hit:FindFirstChild("Health").Value >0 then
humanoid.Value = humanoid.Value -10
end
end
local distance = (position - rayFrom.Position).magnitude
local rayPart = Instance.new("Part", game.Workspace)
rayPart.Name = "RayPart"
rayPart.BrickColor = BrickColor.new("Bright red")
rayPart.Transparency = 0.5
rayPart.Anchored = true
rayPart.CanCollide = false
rayPart.TopSurface = Enum.SurfaceType.Smooth
rayPart.BottomSurface = Enum.SurfaceType.Smooth
rayPart.formFactor = Enum.FormFactor.Custom
rayPart.Size = Vector3.new(0.2, 0.2, distance)
rayPart.CFrame = CFrame.new(position,rayFrom.Position) * CFrame.new(0, 0, -distance/2)
--add it to debris so it disappears after 0.1 seconds
game.Debris:AddItem(rayPart, 0.1)
end
end
end)
--end

while wait(0.1) do
local rayFrom = Character:FindFirstChild("HumanCarrier") or Character:FindFirstChild("HumanCorvette") or
Character:FindFirstChild("Cruiser") or Character:FindFirstChild("Spider")
for _,v in pairs(game.Workspace:GetChildren()) do
local foundShip = v:FindFirstChild("HumanCarrier") or v:FindFirstChild("HumanCorvette") or
v:FindFirstChild("Cruiser") or v:FindFirstChild("Spider")

if foundShip ~= nil and foundShip ~= rayFrom then
local mag = (rayFrom.Position - foundShip.Position).magnitude
if mag <= 200 then
PlayerGui.Target.Frame.Visible = true
PlayerGui.Target.Frame:TweenPosition(UDim2.new(0.2, 0, 0, 0), "In", "Linear", 1)
else if mag > 200 then
print("Too Far")
PlayerGui.Target.Frame:TweenPosition(UDim2.new(0.2, 0, -1, 0), "In", "Linear", 1)
PlayerGui.Target.Frame.Visible = false

end
end

end
end
end

There is the script, where would i add so the turret faces
Report Abuse
blooo127127 is not online. blooo127127
Joined: 22 Jul 2010
Total Posts: 403
24 Mar 2015 09:56 AM
If the turret is welded and you plan on making the turret face a point while welded, good luck. Until I properly learn CFrame, even I wont be able to do that.
Report Abuse
CrowClaws is not online. CrowClaws
Joined: 04 Jul 2010
Total Posts: 4466
24 Mar 2015 10:51 AM
Lol or you could weld everything possible

Put a part on the barrel. Make that part of the bodyposition of the nearest player or whatever

make the base of the turret have a hinge

bam
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