Files
Hunter/scripts/ObjectiveArrows.client.luau
T
2026-11-29 19:54:37 +05:00

124 lines
4.6 KiB
Luau

--!strict
local Players = game:GetService("Players")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local RunService = game:GetService("RunService")
local Modes = require(ReplicatedStorage:WaitForChild("ArenaModes") :: ModuleScript)
local player = Players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local arena = Modes.geometry(Modes.Procedural)
type Arrow = {gui: BillboardGui, chevrons: {Model}, faces: {BasePart}, edges: {BasePart}, glow: {BasePart}, color: Color3?, phase: number}
local arrows: {[BasePart]: Arrow} = {}
local function build(marker: BasePart)
if arrows[marker] then return end
local gui = Instance.new("BillboardGui")
gui.Name = "ObjectiveArrow"
gui.Adornee = marker
gui.AlwaysOnTop = true
gui.LightInfluence = 0
gui.MaxDistance = 710
gui.Size = UDim2.fromOffset(164, 164)
gui.StudsOffsetWorldSpace = Vector3.yAxis * 13
gui.Enabled = false
local viewport = Instance.new("ViewportFrame")
viewport.Name = "ArrowViewport"
viewport.BackgroundTransparency = 1
viewport.Size = UDim2.fromScale(1, 1)
viewport.Ambient = Color3.fromRGB(145, 155, 180)
viewport.LightColor = Color3.new(1, 1, 1)
viewport.LightDirection = Vector3.new(-1, -1, -2)
viewport.Parent = gui
local camera = Instance.new("Camera")
camera.FieldOfView = 31
camera.CFrame = CFrame.lookAt(Vector3.new(0, 0, 9.7), Vector3.zero)
camera.Parent = viewport
viewport.CurrentCamera = camera
local arrow: Arrow = {
gui = gui, chevrons = {}, faces = {}, edges = {}, glow = {}, color = nil, phase = marker.Position.X * .03,
}
for index, scale in {.58, .78, 1} do
local model = Instance.new("Model")
model.Name = "Chevron" .. index
model.Parent = viewport
table.insert(arrow.chevrons, model)
local function piece(name: string, size: Vector3, pose: CFrame, surfaces: {BasePart})
local part = Instance.new("Part")
part.Name = name
part.Size = size * scale
part.CFrame = pose.Rotation + pose.Position * scale
part.Anchored = true
part.CanCollide, part.CanQuery, part.CanTouch = false, false, false
part.Parent = model
table.insert(surfaces, part)
end
for _, side in {-1, 1} do
local pose = CFrame.new(.69 * side, 0, 0) * CFrame.Angles(0, 0, math.rad(-53 * side))
piece("Halo", Vector3.new(.64, 2, .12), pose * CFrame.new(0, 0, -.32), arrow.glow)
piece("LitEdge", Vector3.new(.43, 1.85, .58), pose, arrow.edges)
piece("BrightFace", Vector3.new(.23, 1.68, .07), pose * CFrame.new(0, 0, .29), arrow.faces)
end
model.WorldPivot = CFrame.identity
end
arrows[marker] = arrow
gui.Parent = playerGui
end
local function add(instance: Instance)
if instance:IsA("BasePart") and instance:GetAttribute("ObjectiveArrow") == true then build(instance) end
end
local function remove(instance: Instance)
if not instance:IsA("BasePart") then return end
local arrow = arrows[instance]
if not arrow then return end
arrows[instance] = nil
arrow.gui:Destroy()
end
local added = arena.DescendantAdded:Connect(add)
local removing = arena.DescendantRemoving:Connect(remove)
for _, instance in arena:GetDescendants() do add(instance) end
local render = RunService.RenderStepped:Connect(function()
local camera = workspace.CurrentCamera
local active = player:GetAttribute("InArena") == true and camera ~= nil
local now = os.clock()
for marker, arrow in arrows do
arrow.gui.Enabled = active and marker:GetAttribute("ObjectiveArrowHidden") ~= true
if not arrow.gui.Enabled or not camera then continue end
local distance = (camera.CFrame.Position - marker.Position).Magnitude
if distance > arrow.gui.MaxDistance then continue end
local phase = now * 3 + arrow.phase
local size = math.clamp(math.floor(174 - distance * .11), 104, 174)
arrow.gui.Size = UDim2.fromOffset(size, size)
arrow.gui.StudsOffsetWorldSpace = Vector3.yAxis * (13 + math.sin(phase) * 1.05)
local spacing = 1.15 + math.sin(phase - .9) * .24
for index, chevron in arrow.chevrons do
local level = 2 - index
local tilt = CFrame.Angles(math.rad(-8), .22 + math.sin(phase * .72 + level * .35) * .26, 0)
chevron:PivotTo(CFrame.new(0, level * spacing, 0) * tilt)
end
local color = marker.Color
if arrow.color ~= color then
arrow.color = color
for _, edge in arrow.edges do edge.Color = color end
for _, halo in arrow.glow do halo.Color = color end
for _, face in arrow.faces do face.Color = color:Lerp(Color3.new(1, 1, 1), .64) end
end
for _, halo in arrow.glow do halo.Transparency = .75 + math.sin(phase) * .09 end
end
end)
script.Destroying:Once(function()
added:Disconnect()
removing:Disconnect()
render:Disconnect()
for _, arrow in arrows do arrow.gui:Destroy() end
end)