Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- -- useful functions
- function setValue(name, parent, vector3val)
- local posVal = Instance.new("Vector3Value", parent)
- posVal.Name = name
- posVal.Value = vector3val
- return posVal
- end
- function rotationDifference(angle1, angle2)
- local difference = {x = 0, y = 0, z = 0}
- difference.x = angle2.x - angle1.x
- if difference.x > 180 then
- difference.x = difference.x - 360
- elseif difference.x < -180 then
- difference.x = difference.x + 360
- end
- difference.y = angle2.y - angle1.y
- if difference.y > 180 then
- difference.y = difference.y - 360
- elseif difference.y < -180 then
- difference.y = difference.y + 360
- end
- difference.z = angle2.z - angle1.z
- if difference.z > 180 then
- difference.z = difference.z - 360
- elseif difference.z < -180 then
- difference.z = difference.z + 360
- end
- return Vector3.new(difference.x, difference.y, difference.z)
- end
- function angleDifference(angle1, angle2)
- local difference = 0
- difference = angle2 - angle1
- if difference > 180 then
- difference = difference - 360
- elseif difference < -180 then
- difference = difference + 360
- end
- return difference
- end
- function weldToHumRoot(part, humroot)
- local rweld = Instance.new("Weld", humroot)
- rweld.Part0 = humroot
- rweld.Part1 = part
- return rweld
- end
- --
- local player = game.Players.LocalPlayer
- local char = player.Character
- local camera = workspace.Camera
- repeat wait()
- char = player.Character
- until char
- local model = Instance.new("Model", game.Lighting)
- local mouse = player:GetMouse()
- local p1 = Instance.new("Part", model)
- p1.BrickColor = BrickColor.new("Dark stone grey")
- p1.Material = "Metal"
- p1.Anchored = true
- p1.Shape = "Cylinder"
- p1.Size = Vector3.new(1, 0.9, 0.9)
- p1.CFrame = CFrame.new(-0.05, 0.81, -13.3) *
- CFrame.Angles(math.rad(-180), math.rad(0), math.rad(-180))
- local p2 = Instance.new("Part", model)
- p2.BrickColor = BrickColor.new("Dark stone grey")
- p2.Material = "Metal"
- p2.Anchored = true
- p2.Shape = "Cylinder"
- p2.Size = Vector3.new(1, 0.9, 0.9)
- p2.CFrame = CFrame.new(-0.05, 0.81, -14.3) *
- CFrame.Angles(math.rad(-180), math.rad(0), math.rad(-180))
- local p3 = Instance.new("Part", model)
- p3.BrickColor = BrickColor.new("Dark stone grey")
- p3.Material = "Metal"
- p3.Anchored = true
- p3.Shape = "Cylinder"
- p3.Size = Vector3.new(1, 0.9, 0.9)
- p3.CFrame = CFrame.new(-0.05, 0.81, -12.3) *
- CFrame.Angles(math.rad(-180), math.rad(0), math.rad(-180))
- local p4 = Instance.new("Part", model)
- p4.BrickColor = BrickColor.new("Dark stone grey")
- p4.Material = "Metal"
- p4.Anchored = true
- p4.Shape = "Cylinder"
- p4.Size = Vector3.new(1, 0.9, 0.9)
- p4.CFrame = CFrame.new(2.05, 0.81, -13.3) *
- CFrame.Angles(math.rad(-180), math.rad(0), math.rad(-180))
- local p5 = Instance.new("Part", model)
- p5.BrickColor = BrickColor.new("Dark stone grey")
- p5.Material = "Metal"
- p5.Anchored = true
- p5.Shape = "Cylinder"
- p5.Size = Vector3.new(1, 0.9, 0.9)
- p5.CFrame = CFrame.new(2.05, 0.81, -14.3) *
- CFrame.Angles(math.rad(-180), math.rad(0), math.rad(-180))
- local p6 = Instance.new("Part", model)
- p6.BrickColor = BrickColor.new("Dark stone grey")
- p6.Material = "Metal"
- p6.Anchored = true
- p6.Shape = "Cylinder"
- p6.Size = Vector3.new(1, 0.9, 0.9)
- p6.CFrame = CFrame.new(2.05, 0.81, -12.3) *
- CFrame.Angles(math.rad(-180), math.rad(0), math.rad(-180))
- local p7 = Instance.new("Part", model)
- p7.BrickColor = BrickColor.new("Really black")
- p7.Material = "SmoothPlastic"
- p7.Anchored = true
- p7.Shape = "Block"
- p7.Size = Vector3.new(2, 1, 1)
- p7.CFrame = CFrame.new(2, 0.81, -13.3) *
- CFrame.Angles(math.rad(0), math.rad(90), math.rad(0))
- local p8 = Instance.new("Part", model)
- p8.BrickColor = BrickColor.new("Really black")
- p8.Material = "SmoothPlastic"
- p8.Anchored = true
- p8.Shape = "Cylinder"
- p8.Size = Vector3.new(1, 1, 1)
- p8.CFrame = CFrame.new(2, 0.81, -12.3) *
- CFrame.Angles(math.rad(-180), math.rad(0), math.rad(-180))
- local p9 = Instance.new("Part", model)
- p9.BrickColor = BrickColor.new("Really black")
- p9.Material = "SmoothPlastic"
- p9.Anchored = true
- p9.Shape = "Block"
- p9.Size = Vector3.new(2, 1, 1)
- p9.CFrame = CFrame.new(0, 0.81, -13.3) *
- CFrame.Angles(math.rad(0), math.rad(90), math.rad(0))
- local p10 = Instance.new("Part", model)
- p10.BrickColor = BrickColor.new("Really black")
- p10.Material = "SmoothPlastic"
- p10.Anchored = true
- p10.Shape = "Cylinder"
- p10.Size = Vector3.new(1, 1, 1)
- p10.CFrame = CFrame.new(0, 0.81, -14.3) *
- CFrame.Angles(math.rad(-180), math.rad(0), math.rad(-180))
- local p11 = Instance.new("Part", model)
- p11.BrickColor = BrickColor.new("Really black")
- p11.Material = "SmoothPlastic"
- p11.Anchored = true
- p11.Shape = "Cylinder"
- p11.Size = Vector3.new(1, 1, 1)
- p11.CFrame = CFrame.new(2, 0.81, -14.3) *
- CFrame.Angles(math.rad(-180), math.rad(0), math.rad(-180))
- local p12 = Instance.new("Part", model)
- p12.BrickColor = BrickColor.new("Really black")
- p12.Material = "SmoothPlastic"
- p12.Anchored = true
- p12.Shape = "Cylinder"
- p12.Size = Vector3.new(1, 1, 1)
- p12.CFrame = CFrame.new(0, 0.81, -12.3) *
- CFrame.Angles(math.rad(-180), math.rad(0), math.rad(-180))
- local p13 = Instance.new("Part", model)
- p13.BrickColor = BrickColor.new("Medium stone grey")
- p13.Material = "Metal"
- p13.Anchored = true
- p13.Shape = "Block"
- p13.Size = Vector3.new(0.8, 0.2, 1)
- p13.CFrame = CFrame.new(2, 1.41, -12.6) *
- CFrame.Angles(math.rad(0), math.rad(90), math.rad(0))
- local p14 = Instance.new("Part", model)
- p14.BrickColor = BrickColor.new("Medium stone grey")
- p14.Material = "Metal"
- p14.Anchored = true
- p14.Shape = "Block"
- p14.Size = Vector3.new(0.8, 0.2, 1)
- p14.CFrame = CFrame.new(0, 1.41, -12.6) *
- CFrame.Angles(math.rad(0), math.rad(90), math.rad(0))
- local p15 = Instance.new("Part", model)
- p15.BrickColor = BrickColor.new("Medium stone grey")
- p15.Material = "Metal"
- p15.Anchored = true
- p15.Shape = "Block"
- p15.Size = Vector3.new(0.2, 0.7, 0.8)
- p15.CFrame = CFrame.new(1, 1.06, -12.2) *
- CFrame.Angles(math.rad(0), math.rad(90), math.rad(0))
- local p16 = Instance.new("Part", model)
- p16.BrickColor = BrickColor.new("Medium stone grey")
- p16.Material = "Metal"
- p16.Anchored = true
- p16.Shape = "Block"
- p16.Size = Vector3.new(1.2, 0.9, 1)
- p16.CFrame = CFrame.new(1, 1.06, -12.8) *
- CFrame.Angles(math.rad(0), math.rad(90), math.rad(0))
- local p17 = Instance.new("WedgePart", model)
- p17.BrickColor = BrickColor.new("Medium stone grey")
- p17.Material = "Metal"
- p17.Anchored = true
- p17.Size = Vector3.new(1, 0.4, 1.1)
- p17.CFrame = CFrame.new(1, 0.81, -13.95) *
- CFrame.Angles(math.rad(0), math.rad(0), math.rad(-180))
- local p18 = Instance.new("WedgePart", model)
- p18.BrickColor = BrickColor.new("Medium stone grey")
- p18.Material = "Metal"
- p18.Anchored = true
- p18.Size = Vector3.new(1, 0.2, 0.7)
- p18.CFrame = CFrame.new(2, 1.41, -13.35) *
- CFrame.Angles(math.rad(0), math.rad(0), math.rad(0))
- local p19 = Instance.new("WedgePart", model)
- p19.BrickColor = BrickColor.new("Medium stone grey")
- p19.Material = "Metal"
- p19.Anchored = true
- p19.Size = Vector3.new(1, 0.5, 1.1)
- p19.CFrame = CFrame.new(1, 1.26, -13.95) *
- CFrame.Angles(math.rad(0), math.rad(0), math.rad(0))
- local p20 = Instance.new("WedgePart", model)
- p20.BrickColor = BrickColor.new("Medium stone grey")
- p20.Material = "Metal"
- p20.Anchored = true
- p20.Size = Vector3.new(1, 0.2, 0.7)
- p20.CFrame = CFrame.new(0, 1.41, -13.35) *
- CFrame.Angles(math.rad(0), math.rad(0), math.rad(0))
- local p21 = Instance.new("Part", model)
- p21.BrickColor = BrickColor.new("Medium stone grey")
- p21.Material = "Metal"
- p21.Anchored = true
- p21.Shape = "Cylinder"
- p21.Size = Vector3.new(0.8, 0.2, 0.2)
- p21.CFrame = CFrame.new(1.4, 1.01, -12.2) *
- CFrame.Angles(math.rad(180), math.rad(0), math.rad(90))
- local p22 = Instance.new("Part", model)
- p22.BrickColor = BrickColor.new("Medium stone grey")
- p22.Material = "Metal"
- p22.Anchored = true
- p22.Shape = "Cylinder"
- p22.Size = Vector3.new(0.8, 0.2, 0.2)
- p22.CFrame = CFrame.new(0.6, 1.01, -12.2) *
- CFrame.Angles(math.rad(180), math.rad(0), math.rad(90))
- local p23 = Instance.new("Part", model)
- p23.BrickColor = BrickColor.new("Medium stone grey")
- p23.Material = "Metal"
- p23.Anchored = true
- p23.Shape = "Cylinder"
- p23.Size = Vector3.new(0.8, 0.2, 0.2)
- p23.CFrame = CFrame.new(1, 0.71, -12.2) *
- CFrame.Angles(math.rad(-180), math.rad(0), math.rad(-180))
- local p24 = Instance.new("Part", model)
- p24.BrickColor = BrickColor.new("Medium stone grey")
- p24.Material = "Metal"
- p24.Anchored = true
- p24.Shape = "Cylinder"
- p24.Size = Vector3.new(3, 0.2, 0.2)
- p24.CFrame = CFrame.new(1, 1.41, -12.2) *
- CFrame.Angles(math.rad(-180), math.rad(0), math.rad(-180))
- --
- local p25 = Instance.new("Part", model)
- p25.Name = "RotatingTurret"
- p25.BrickColor = BrickColor.new("Medium stone grey")
- p25.Material = "Metal"
- p25.Anchored = true
- p25.Shape = "Cylinder"
- p25.Size = Vector3.new(0.1, 0.5, 0.5)
- p25.CFrame = CFrame.new(1, 1.56, -12.8) *
- CFrame.Angles(math.rad(0), math.rad(-90), math.rad(90))
- local p26 = Instance.new("Part", p25)
- p26.Name = "TurretPart"
- p26.BrickColor = BrickColor.new("Medium stone grey")
- p26.Material = "Metal"
- p26.Anchored = true
- p26.Shape = "Block"
- p26.Size = Vector3.new(1, 0.6, 1)
- setValue("PosVal", p26, Vector3.new(0.25, 0, 0))
- setValue("RotVal", p26, Vector3.new(0, 0, 90))
- local p27 = Instance.new("Part", p26)
- p27.Name = "RotatingBarrel"
- p27.BrickColor = BrickColor.new("Medium stone grey")
- p27.Material = "Metal"
- p27.Anchored = true
- p27.Shape = "Ball"
- p27.Size = Vector3.new(0.4, 0.4, 0.4)
- setValue("PosVal", p27, Vector3.new(0.5, 0, 0))
- setValue("RotVal", p27, Vector3.new(0, 0, 0))
- local p28 = Instance.new("Part", p27)
- p28.Name = "TurretBarrelPart"
- p28.BrickColor = BrickColor.new("Medium stone grey")
- p28.Material = "Metal"
- p28.Anchored = true
- p28.Shape = "Cylinder"
- p28.Size = Vector3.new(1.2, 0.4, 0.4)
- setValue("PosVal", p28, Vector3.new(0.6, 0, 0))
- setValue("RotVal", p28, Vector3.new(0, 0, 0))
- local p29 = Instance.new("Part", p27)
- p29.Name = "TurretBarrelPart"
- p29.BrickColor = BrickColor.new("Medium stone grey")
- p29.Material = "Metal"
- p29.Anchored = true
- p29.Shape = "Cylinder"
- p29.Size = Vector3.new(0.5, 0.475, 0.475)
- setValue("PosVal", p29, Vector3.new(1, 0, 0))
- setValue("RotVal", p29, Vector3.new(0, 0, 0))
- local p30 = Instance.new("Part", p27)
- p30.Name = "TurretBarrelExit"
- p30.Color = Color3.new(0, 0, 0)
- p30.Material = "SmoothPlastic"
- p30.Anchored = true
- p30.Shape = "Cylinder"
- p30.Size = Vector3.new(0.05, 0.3, 0.3)
- setValue("PosVal", p30, Vector3.new(1.23, 0, 0))
- setValue("RotVal", p30, Vector3.new(0, 0, 0))
- --
- local turrets = {}
- local rfp = CFrame.new(1, 1, -13)
- char.HumanoidRootPart.Size = Vector3.new(1, 0, 1)
- weldToHumRoot(char.HumanoidRootPart, char.Torso)
- char.Torso.Neck.C1 = CFrame.new(0, 0, 0)
- char.Torso.Neck.C0 = CFrame.new(0, 0, 0)
- local clonedNeck = char.Torso.Neck:Clone()
- char.Head.Size = Vector3.new(0, 0, 0)
- char.Torso.Size = Vector3.new(0, 0, 0)
- clonedNeck.Parent = char.Torso
- weldToHumRoot(char.Torso, char.HumanoidRootPart)
- char.Humanoid.HipHeight = 0.67
- --char.Torso.Size = Vector3.new(1, 0, 1)
- --weldToHumRoot(char.Torso, char.HumanoidRootPart)
- --local mseUnitRot, mseAngle -- don't mind this
- --local mouseAngle -- the angle of the mouse
- function Update()
- --local mseUnitRot, mseAngle = CFrame.new(camera.CFrame.p, mouse.Hit.p):toAxisAngle()
- --local mouseAngle = mseUnitRot * math.deg(mseAngle)
- --print("Mouse Rotation: " .. mouseAngle.Y .. ", " .. mouseAngle.X)
- for _,weld in pairs(turrets) do
- local mseUnitRot, mseAngle = CFrame.new(weld.Parent.CFrame.p, mouse.Hit.p):toAxisAngle()
- local mouseAngle = mseUnitRot * math.deg(mseAngle)
- weld.C0 = CFrame.Angles(-math.rad(angleDifference(char.HumanoidRootPart.Orientation.Y, mouseAngle.Y)), 0, 0)
- for _,bweld in pairs(weld:GetChildren()) do
- if bweld.Name == "Barrel" and bweld:IsA("ValueBase") then
- mseUnitRot, mseAngle = CFrame.new(bweld.Value.Parent.CFrame.p, mouse.Hit.p):toAxisAngle()
- mouseAngle = mseUnitRot * math.deg(mseAngle)
- bweld.Value.C0 = CFrame.Angles(0, 0, math.rad(angleDifference(char.HumanoidRootPart.Orientation.X, mouseAngle.X)))
- end
- end
- end
- end
- Update()
- game:GetService("RunService").RenderStepped:connect(Update)
- for _,v in pairs(model:GetChildren()) do
- if v:IsA("BasePart") then
- local part = v:Clone()
- part.Parent = char
- part.Anchored = false
- local weld = Instance.new("Weld", part)
- weld.Part0 = part
- weld.Part1 = char.Torso
- weld.C1 = CFrame.new(v.CFrame.X - rfp.X,
- v.CFrame.Y - rfp.Y,
- v.CFrame.Z - rfp.Z)
- *
- CFrame.Angles(math.rad(v.Rotation.X), math.rad(v.Rotation.Y), math.rad(v.Rotation.Z))
- if part.Name == "RotatingTurret" then
- turrets[table.getn(turrets) + 1] = weld
- for _,trrt in pairs(part:GetChildren()) do
- if trrt:IsA("BasePart") then
- print("turret adedd")
- trrt.Anchored = false
- local tweld = Instance.new("Weld", trrt)
- tweld.Part0 = trrt
- tweld.Part1 = part
- tweld.C1 = CFrame.new(trrt.PosVal.Value.X,
- trrt.PosVal.Value.Y,
- trrt.PosVal.Value.Z)
- *
- CFrame.Angles(math.rad(trrt.RotVal.Value.X), math.rad(trrt.RotVal.Value.Y), math.rad(trrt.RotVal.Value.Z))
- local turretCount = table.getn(turrets)
- for _,rotbrrl in pairs(trrt:GetChildren()) do
- if rotbrrl:IsA("BasePart") then
- rotbrrl.Anchored = false
- local bweld = Instance.new("Weld", rotbrrl)
- bweld.Part0 = rotbrrl
- bweld.Part1 = trrt
- bweld.C1 = CFrame.new(rotbrrl.PosVal.Value.X,
- rotbrrl.PosVal.Value.Y,
- rotbrrl.PosVal.Value.Z)
- *
- CFrame.Angles(math.rad(rotbrrl.RotVal.Value.X), math.rad(rotbrrl.RotVal.Value.Y), math.rad(rotbrrl.RotVal.Value.Z))
- local brrlRef = Instance.new("ObjectValue", turrets[turretCount])
- brrlRef.Name = "Barrel"
- brrlRef.Value = bweld
- for _,brrlpart in pairs(rotbrrl:GetChildren()) do
- if brrlpart:IsA("BasePart") then
- brrlpart.Anchored = false
- local bpweld = Instance.new("Weld", rotbrrl)
- bpweld.Part0 = brrlpart
- bpweld.Part1 = rotbrrl
- bpweld.C1 = CFrame.new(brrlpart.PosVal.Value.X,
- brrlpart.PosVal.Value.Y,
- brrlpart.PosVal.Value.Z)
- *
- CFrame.Angles(math.rad(brrlpart.RotVal.Value.X), math.rad(brrlpart.RotVal.Value.Y), math.rad(brrlpart.RotVal.Value.Z))
- if brrlpart.Name == "TurretBarrelExit" then
- setValue("ExitPos", rotbrrl, brrlpart.PosVal.Value)
- end
- end
- end
- end
- end
- end
- end
- end
- end
- end
- char.Humanoid.WalkSpeed = 24
- char.Humanoid.MaxHealth = 400
- char.Humanoid.Health = char.Humanoid.MaxHealth
- char.Head.Transparency = 1
- char.Torso.Transparency = 1
- char["Right Leg"]:Destroy()
- char["Left Leg"]:Destroy()
- char["Right Arm"]:Destroy()
- char["Left Arm"]:Destroy()
- char.Head:WaitForChild("face"):Destroy()
- for _,h in pairs(char:GetChildren()) do
- if h.ClassName == "Accessory" then h:Destroy() end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement