local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local Debris = game:GetService("Debris")
local Sentry = script.Parent
local Main_Sentry = Sentry:WaitForChild("Main_Sentry")
local Ray_Origin = Main_Sentry:WaitForChild("Ray_Origin")
local MAX_RANGE = 100
local COOLDOWN = 0.1
local function Visualizer(Origin, End_Position, Distance, LASER_COLOR)
local Laser = Instance.new("Part")
Laser.CanCollide = false
Laser.CanTouch = false
Laser.CanQuery = false
Laser.CastShadow = false
Laser.Anchored = true
Laser.Color = LASER_COLOR
Laser.Material = Enum.Material.Neon
Laser.Size = Vector3.new(0.2, 0.2, Distance)
Laser.CFrame = CFrame.lookAt(Origin, End_Position) * CFrame.new(Vector3.new(0, 0, -Distance/2))
Laser.Parent = workspace
Debris:AddItem(Laser, 0.1)
end
while true do
for i, player in Players:GetPlayers() do
local character = player.Character or player.CharacterAdded:Wait()
local HRP = character:WaitForChild("HumanoidRootPart")
local Distance = (HRP.Position - Ray_Origin.WorldCFrame.Position).Magnitude
if Distance > MAX_RANGE then continue end
local Origin = Ray_Origin.WorldCFrame.Position
local Direction = ((HRP.Position - Main_Sentry.Position).Unit) * MAX_RANGE
local RaycastParameters = RaycastParams.new()
RaycastParameters.FilterType = Enum.RaycastFilterType.Exclude
RaycastParameters.FilterDescendantsInstances = {Sentry}
RaycastParameters.IgnoreWater = true
local RayResults = workspace:Raycast(Origin, Direction, RaycastParameters)
if not RayResults then
print("Hit Nothing!")
else
print("Hit: ".. RayResults.Instance.Name)
if RayResults.Instance.Name == "Handle" and RayResults.Instance.Parent:IsA("Accessory") and Players:GetPlayerFromCharacter(RayResults.Instance.Parent.Parent) or Players:GetPlayerFromCharacter(RayResults.Instance.Parent) then
local LookAt_CFrame = CFrame.lookAt(Origin, RayResults.Position)
local X, Y, Z = LookAt_CFrame:ToOrientation()
Visualizer(Origin, RayResults.Position, RayResults.Distance, Color3.fromRGB(0, 255, 0))
TweenService:Create(Main_Sentry, TweenInfo.new(0.25, Enum.EasingStyle.Linear), {Orientation = Vector3.new(math.deg(X), math.deg(Y), math.deg(Z))}):Play()
else
Visualizer(Origin, RayResults.Position, RayResults.Distance, Color3.fromRGB(255, 0, 0))
end
end
end
task.wait(COOLDOWN)
end
I’m trying to get the entire upper part of the sentry to rotate as its shooting the player but I’m not sure how to rotate the entire thing. I can only rotate one part and that’s it.





