local TweenService = game:GetService("TweenService")
local Players = game:GetService("Players")
local Debris = game:GetService("Debris")
local Sentry = script.Parent
local Sentry_Head = Sentry:WaitForChild("Sentry_Head")
local Ray_Origin = Sentry_Head: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.1, 0.1, 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
if not player.Character or not player.Character:FindFirstChild("HumanoidRootPart") then continue end
local character = player.Character or player.CharacterAdded:Wait()
local HRP = character:WaitForChild("HumanoidRootPart")
local Distance = (Sentry_Head.Position - HRP.Position).Magnitude
if Distance > MAX_RANGE then continue end
local Origin = Ray_Origin.WorldCFrame.Position
local Direction = HRP.Position - Origin
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)
local Hit_Instance = RayResults.Instance
local Hit_Position = RayResults.Position
local Hit_Distance = RayResults.Distance
if Hit_Instance.Name == "Handle" and Hit_Instance.Parent:IsA("Accessory") and Players:GetPlayerFromCharacter(Hit_Instance.Parent.Parent) or Players:GetPlayerFromCharacter(Hit_Instance.Parent) then
local LookAt_CFrame = CFrame.lookAt(Origin, Hit_Position)
local X, Y, Z = LookAt_CFrame:ToOrientation()
local New_Orientation = Vector3.new(math.deg(X), math.deg(Y), math.deg(Z))
TweenService:Create(Sentry_Head, TweenInfo.new(0.25, Enum.EasingStyle.Linear), {Orientation = New_Orientation}):Play()
Visualizer(Origin, Hit_Position, Hit_Distance, Color3.fromRGB(0, 255, 0))
else
Visualizer(Origin, Hit_Position, Hit_Distance, Color3.fromRGB(255, 0, 0))
end
end
end
task.wait(COOLDOWN)
end
I’m trying to use tween service to rotate the sentry’s head smoothly to look at the player but the welded parts won’t rotate along with it. I don’t know how to fix this.



