--!strict local Text = require(game:GetService("ReplicatedStorage"):WaitForChild("Hunter"):WaitForChild("Strings") :: ModuleScript).interface.DamageNumbers -- LocalScript in StarterPlayerScripts. -- Floating damage numbers for the shooter: the server confirms each hit -- (ReplicatedStorage.SniperHit: position, damage, zone, killed) and the number pops out where the -- bullet went, then floats up and fades. Head = big yellow number with a red "КРИТ" tag, body = -- white, arms / legs = smaller grey. Each number drifts a bit to the side, so a burst scatters. local ReplicatedStorage = game:GetService("ReplicatedStorage") local TweenService = game:GetService("TweenService") local hitRemote = ReplicatedStorage:WaitForChild("SniperHit") :: RemoteEvent local SniperEffects = require(ReplicatedStorage:WaitForChild("SniperEffects")) :: any -- DmgNumSpread / DmgNumRise (SniperViewmodel attributes): how far the numbers fly to the side -- and up, 1 = normal. The hit sound also plays here (it is the shooter's confirm). local LIFE = 0.9 -- seconds on screen type Style = { size: number, color: Color3, stroke: Color3 } local STYLES: { [string]: Style } = { Head = { size = 42, color = Color3.fromRGB(255, 214, 40), stroke = Color3.fromRGB(60, 25, 0) }, Body = { size = 30, color = Color3.fromRGB(255, 255, 255), stroke = Color3.fromRGB(20, 20, 28) }, Limb = { size = 24, color = Color3.fromRGB(205, 210, 222), stroke = Color3.fromRGB(20, 20, 28) }, } local CRIT_COLOR = Color3.fromRGB(255, 45, 45) local function textLabel(parent: Instance, text: string, size: number, color: Color3, stroke: Color3, strokeSize: number): TextLabel local l = Instance.new("TextLabel") l.BackgroundTransparency = 1 l.Size = UDim2.fromScale(1, 0) l.AutomaticSize = Enum.AutomaticSize.Y l.Font = Enum.Font.FredokaOne l.Text = text l.TextSize = size l.TextColor3 = color local s = Instance.new("UIStroke") s.Color = stroke s.Thickness = strokeSize s.LineJoinMode = Enum.LineJoinMode.Round s.Parent = l l.Parent = parent return l end local ICON = 64 -- px local TARGET_RED = Color3.fromRGB(230, 30, 30) local OUTLINE = Color3.fromRGB(20, 20, 28) -- headshot kill: a red target (thick ring, a dot, four ticks crossing the ring) local function targetIcon(parent: Instance): Frame local icon = Instance.new("Frame") icon.Size = UDim2.fromOffset(ICON, ICON) icon.BackgroundTransparency = 1 local ring = Instance.new("Frame") ring.AnchorPoint = Vector2.new(0.5, 0.5) ring.Position = UDim2.fromScale(0.5, 0.5) ring.Size = UDim2.fromOffset(ICON * 0.62, ICON * 0.62) ring.BackgroundTransparency = 1 local rc = Instance.new("UICorner") rc.CornerRadius = UDim.new(1, 0) rc.Parent = ring local rs = Instance.new("UIStroke") rs.Color = TARGET_RED rs.Thickness = 7 rs.Parent = ring ring.Parent = icon local function bar(x: number, y: number, w: number, h: number) local f = Instance.new("Frame") f.AnchorPoint = Vector2.new(0.5, 0.5) f.Position = UDim2.new(0.5, x, 0.5, y) f.Size = UDim2.fromOffset(w, h) f.BackgroundColor3 = TARGET_RED f.BorderSizePixel = 0 local s = Instance.new("UIStroke") s.Color = OUTLINE s.Thickness = 1.5 s.ApplyStrokeMode = Enum.ApplyStrokeMode.Border s.Parent = f f.Parent = icon end local r = ICON * 0.36 bar(0, -r, 6, 18) bar(0, r, 6, 18) bar(-r, 0, 18, 6) bar(r, 0, 18, 6) bar(0, 0, 12, 12) -- the bullseye icon.Parent = parent return icon end -- body kill: a skull local function skullIcon(parent: Instance): TextLabel local l = Instance.new("TextLabel") l.BackgroundTransparency = 1 l.Size = UDim2.fromOffset(ICON, ICON) l.Text = "💀" l.TextSize = 52 l.Parent = parent return l end local function popup(position: Vector3, damage: number, zone: string, killed: boolean) local style = STYLES[zone] or STYLES.Body local anchor = Instance.new("Attachment") anchor.WorldPosition = position anchor.Parent = workspace.Terrain local gui = Instance.new("BillboardGui") local height = if killed then 190 else 90 -- a kill also carries an icon and a caption gui.Size = UDim2.fromOffset(160, height) gui.AlwaysOnTop = true gui.LightInfluence = 0 gui.MaxDistance = 1000 gui.Adornee = anchor gui.Parent = anchor local group = Instance.new("Frame") -- (a CanvasGroup does not draw inside a BillboardGui) group.BackgroundTransparency = 1 group.Size = UDim2.fromScale(1, 1) group.Parent = gui local list = Instance.new("UIListLayout") list.HorizontalAlignment = Enum.HorizontalAlignment.Center list.VerticalAlignment = Enum.VerticalAlignment.Bottom list.Padding = UDim.new(0, -6) list.Parent = group local scale = Instance.new("UIScale") scale.Scale = 1.9 scale.Parent = group if killed then -- a kill: icon (a red target for the head, a skull otherwise), then the caption if zone == "Head" then targetIcon(group).LayoutOrder = 0 else skullIcon(group).LayoutOrder = 0 end local caption = textLabel(group, if zone == "Head" then Text.khedshot else Text.ubit, 22, Color3.new(1, 1, 1), Color3.fromRGB(20, 20, 28), 2.5) caption.Font = Enum.Font.GothamBlack caption.LayoutOrder = 1 elseif zone == "Head" then local crit = textLabel(group, Text.krit, 24, CRIT_COLOR, Color3.new(1, 1, 1), 2.5) crit.Rotation = -8 crit.LayoutOrder = 1 end textLabel(group, tostring(damage), style.size, style.color, style.stroke, 3).LayoutOrder = 3 -- pop in, then fly off to one side and up, fading at the end. SizeOffset is in units of the -- gui's own (pixel) size, so the flight is the same on screen near and far. local spread = SniperEffects.setting("DmgNumSpread", 1) local rise = SniperEffects.setting("DmgNumRise", 1) local side = (if math.random() < 0.5 then -1 else 1) * (0.7 + math.random() * 0.9) * spread -- 110..250 px at 1 local up = (0.4 + math.random() * 0.6) * rise * 90 / height -- same flight in pixels for a taller gui local life = LIFE if killed then -- a kill flies straight up, high (about 200 px at 1), and stays a little longer side = (math.random() - 0.5) * 0.15 up = (1.9 + math.random() * 0.4) * SniperEffects.setting("KillPopRise", 1) * 90 / height life = LIFE * 1.5 end TweenService:Create(scale, TweenInfo.new(0.14, Enum.EasingStyle.Back, Enum.EasingDirection.Out), { Scale = 1 }):Play() TweenService:Create(gui, TweenInfo.new(life, Enum.EasingStyle.Quart, Enum.EasingDirection.Out), { SizeOffset = Vector2.new(side, up), }):Play() local fade = TweenInfo.new(0.35, Enum.EasingStyle.Linear, Enum.EasingDirection.In, 0, false, life - 0.35) for _, d in group:GetDescendants() do if d:IsA("TextLabel") then TweenService:Create(d, fade, { TextTransparency = 1 }):Play() elseif d:IsA("UIStroke") then TweenService:Create(d, fade, { Transparency = 1 }):Play() elseif d:IsA("Frame") and d.BackgroundTransparency < 1 then -- the target icon's strokes TweenService:Create(d, fade, { BackgroundTransparency = 1 }):Play() end end task.delay(life, function() anchor:Destroy() end) end hitRemote.OnClientEvent:Connect(function(position: unknown, damage: unknown, zone: unknown, killed: unknown) if typeof(position) == "Vector3" and typeof(damage) == "number" and typeof(zone) == "string" then popup(position, damage, zone, killed == true) end end)