← KEMBALI KE SCRIPT LIBRARY

Ghidorah

UmumVersi 1.0Update 26/11/2026

Ghidorah versi 1 dan Versi 2 Ghidorah Void Premium

Cara penggunaan
-
Lokasi pemasangan
Script di ServerScriptService
ScriptVersi 1
--[[
	KING GHIDORAH v1 STUD - BADAN TUMPUKAN STUD GEMUK - Roblox Studio Lite
	CARA PAKAI:
	1. Part di Workspace bernama persis: GhidorahPlace (Anchored, besar, mis. 150x2x150)
	2. buat Script (BUKAN LocalScript) di ServerScriptService, paste kode ini
	3. Ganti ROAR_SOUND_ID dengan ID sound roar kamu (kalau dibiarkan 0, suara dilewati, tidak error)
	4. Play. Ubah SCALE untuk membesar/mengecil.
	Perubahan v7: badan baru = 6 lapis brick bertumpuk (perut buncit) + dinding brick di perut & dada,
	bahu 3 tingkat, punggung berlapis. Kepala/leher/kaki/ekor/sayap sama seperti v6.
	Jangkauan: deteksi 110, api 100 (otomatis dijaga supaya tidak saling bertabrakan).
]]

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")

---------------------------------------------------------------- CONFIG
local SCALE = 1
local ROAR_SOUND_ID = "rbxassetid://0"       -- <<< GANTI ID SOUND ROAR DI SINI
local ROAR_VOLUME = 4
local DETECT_RANGE = 110
local FIRE_RANGE = 100
local BITE_TRIGGER = 60
local BITE_RANGE = 45
local BITE_DAMAGE = 25
local FIRE_DAMAGE = 6                        -- per tick (0.25 detik)
local FIRE_DURATION = 3
local FIRE_COOLDOWN = 6
local FLY_HEIGHT = 10                        -- melayang rendah
local ANIM_FPS = 20                          -- lebih kecil = lebih ringan
local FACE_PLAYER = true

-- jaga urutan jarak supaya logika AI tidak rusak: gigit < api <= deteksi
FIRE_RANGE = math.min(FIRE_RANGE, DETECT_RANGE)
BITE_TRIGGER = math.min(BITE_TRIGGER, FIRE_RANGE - 10)
BITE_RANGE = math.min(BITE_RANGE, BITE_TRIGGER)

local RED = Color3.fromRGB(215, 15, 25)
local DARK_RED = Color3.fromRGB(165, 10, 20)
local BLACK = Color3.fromRGB(22, 22, 26)
local GOLD = Color3.fromRGB(250, 195, 20)
local DARK_GOLD = Color3.fromRGB(205, 150, 10)
local WHITE = Color3.fromRGB(245, 245, 245)
local EYE = Color3.fromRGB(255, 30, 30)
local PLASTIC = Enum.Material.Plastic

---------------------------------------------------------------- CARI PLACE
local place = Workspace:WaitForChild("GhidorahPlace", 15)
if not place or not place:IsA("BasePart") then
	warn("[Ghidorah] Part bernama 'GhidorahPlace' tidak ditemukan di Workspace!")
	return
end
local old = Workspace:FindFirstChild("Ghidorah")
if old then old:Destroy() end

---------------------------------------------------------------- HELPER BUILD
local S = SCALE
local function V(x, y, z) return Vector3.new(x * S, y * S, z * S) end
local function C(x, y, z) return CFrame.new(x * S, y * S, z * S) end

local model = Instance.new("Model")
model.Name = "Ghidorah"

local SURFACES = { "TopSurface", "BottomSurface", "LeftSurface", "RightSurface", "FrontSurface", "BackSurface" }

local function newPart(name, sx, sy, sz, color)
	local p = Instance.new("Part")
	p.Name = name
	p.Size = V(sx, sy, sz)
	p.Color = color
	p.Material = PLASTIC
	p.Anchored = false
	p.CanCollide = false
	p.CanTouch = false
	p.CanQuery = false
	p.Massless = true
	p.CastShadow = false
	for _, sn in ipairs(SURFACES) do
		p[sn] = Enum.SurfaceType.Studs
	end
	p.Parent = model
	return p
end

local J = {}
local function joint(name, p0, p1, c0, c1)
	local m = Instance.new("Motor6D")
	m.Name = name
	m.Part0 = p0
	m.Part1 = p1
	m.C0 = c0
	m.C1 = c1 or CFrame.new()
	m.Parent = p0
	p1.CFrame = p0.CFrame * c0 * m.C1:Inverse()
	J[name] = { m = m, base = c0 }
	return m
end

local decoCount = 0
local function deco(parent, sx, sy, sz, color, c0)
	decoCount += 1
	local name = "D" .. decoCount
	local p = newPart(name, sx, sy, sz, color)
	joint(name, parent, p, c0)
	return p
end

---------------------------------------------------------------- TORSO TUMPUKAN STUD (6 LAPIS, GEMUK)
local root = newPart("Body", 22, 10, 16, BLACK)
root.Anchored = true
root.CFrame = CFrame.new()
model.PrimaryPart = root

local LW = { 20, 27, 31, 30, 26, 20 }   -- lebar tiap lapis (perut & dada paling lebar)
local LD = { 14, 19, 22, 21, 18, 14 }   -- kedalaman
for i = 1, 6 do
	local y = -5 + (i - 1) * 2.4
	local w, d = LW[i], LD[i]
	local even = (i % 2 == 0)
	deco(root, w - 6.4, 2.3, d, even and RED or BLACK, C(0, y, 0))              -- slab tengah
	for _, s in ipairs({ -1, 1 }) do
		deco(root, 3.3, 2.3, d - 1, even and GOLD or DARK_RED, C(s * (w / 2 - 1.65), y, 0)) -- brick sisi
	end
end

-- perut: dinding brick 3 x 2 (stud menghadap depan)
for ix = -1, 1 do
	for iy = 0, 1 do
		local c = ((ix + iy) % 2 == 0) and GOLD or DARK_GOLD
		deco(root, 4, 2.6, 3.5, c, C(ix * 4.2, -3.6 + iy * 2.8, -10.8))
	end
end

-- dada: dinding brick 2 x 2 + permata bercahaya
for _, s in ipairs({ -1, 1 }) do
	for iy = 0, 1 do
		local c = (iy == 0) and GOLD or RED
		deco(root, 5, 2.6, 3, c, C(s * 5.6, 3.4 + iy * 2.8, -10.4))
	end
end
deco(root, 6, 6, 2, GOLD, C(0, 4.8, -10))
local gem = deco(root, 3.6, 3.6, 1.6, RED, C(0, 4.8, -11.4))
gem.Material = Enum.Material.Neon
local gl = Instance.new("PointLight")
gl.Color = Color3.fromRGB(255, 40, 40)
gl.Brightness = 2
gl.Range = 16
gl.Parent = gem

-- kerah (dasar leher)
deco(root, 16, 1.6, 10, GOLD, C(0, 8.8, -3))

-- punggung berlapis + duri
for i = 0, 2 do
	deco(root, 17 - i * 2.5, 2.4, 2.6, (i == 1) and RED or BLACK, C(0, -2 + i * 3, 11.9))
end
for i = 0, 2 do
	deco(root, 3, 4, 3.4, GOLD, C(0, 4.6 - i * 3.2, 14.2))
end

-- bahu 3 tingkat + tanduk
for _, s in ipairs({ -1, 1 }) do
	deco(root, 8, 2.6, 10, GOLD, C(s * 14.5, 3.6, 0))
	deco(root, 6.4, 2.2, 8.4, BLACK, C(s * 14.5, 5.6, 0))
	deco(root, 4.6, 2, 6.4, GOLD, C(s * 14.5, 7.4, 0))
	deco(root, 2, 6, 2, GOLD, C(s * 15, 11.2, -1) * CFrame.Angles(0, 0, -s * 0.3))
end

---------------------------------------------------------------- KAKI (pendek, tebal)
for _, s in ipairs({ -1, 1 }) do
	local tag = (s < 0) and "L" or "R"
	local thigh = newPart("Thigh" .. tag, 10, 5, 10, BLACK)
	joint("Thigh" .. tag, root, thigh, C(s * 8, -4, 0), C(0, 2.5, 0))
	deco(thigh, 11, 2, 11, RED, C(0, 1.2, 0))
	deco(thigh, 6, 3, 2, GOLD, C(0, -0.5, -5.6))

	local shin = newPart("Shin" .. tag, 9, 4, 9, BLACK)
	joint("Shin" .. tag, thigh, shin, C(0, -2.5, 0), C(0, 2, 0))
	deco(shin, 10, 1.4, 10, GOLD, C(0, -0.8, 0))
	deco(shin, 5, 2, 2, RED, C(0, 0.4, -5))

	local foot = newPart("Foot" .. tag, 11, 2.5, 13, BLACK)
	joint("Foot" .. tag, shin, foot, C(0, -2, 0), C(0, 1.25, 2))
	for i = -1, 1 do
		deco(foot, 2.8, 2.2, 4.5, GOLD, C(i * 3.6, 0, -8.4))
	end
end

---------------------------------------------------------------- EKOR (6 ruas, tebal)
local NT = 6
do
	local prev = root
	local TL = 8
	for i = 1, NT do
		local w, h = math.max(3.6, 14 - i * 1.7), math.max(3, 9 - i * 1)
		local seg = newPart("Tail" .. i, w, h, TL, (i % 2 == 1) and BLACK or RED)
		if i == 1 then
			joint("Tail1", root, seg, C(0, -3, 8), C(0, 0, -TL / 2))
		else
			joint("Tail" .. i, prev, seg, C(0, 0, TL / 2), C(0, 0, -TL / 2))
		end
		deco(seg, 1.8, math.max(2, 4 - i * 0.3), 3, GOLD, C(0, h / 2 + 1.2, 0))
		deco(seg, w * 0.6, 1, TL - 0.6, GOLD, C(0, -h / 2 - 0.4, 0))
		if i == NT then
			deco(seg, 2.4, 2.4, 6, GOLD, C(0, 0, TL / 2 + 2.5))
		end
		prev = seg
	end
end

---------------------------------------------------------------- SAYAP (ringkas)
local REST_H, REST_F = 0.85, 0.5
local function strip(parent, xo, w, h, rest, s, color)
	decoCount += 1
	local name = "D" .. decoCount
	local p = newPart(name, w, h, 0.5, color)
	joint(name, parent, p, C(xo, 0, 0) * CFrame.Angles(0, 0, -s * rest) * C(0, -h / 2 - 0.5, 0))
	return p
end

for _, s in ipairs({ -1, 1 }) do
	local tag = (s < 0) and "L" or "R"
	local hum = newPart("Hum" .. tag, 14, 3, 3, BLACK)
	joint("Hum" .. tag, root, hum, C(s * 13, 4, 6), C(-s * 7, 0, 0))
	deco(hum, 14, 1.3, 1.3, GOLD, C(0, 2, 0))

	local fore = newPart("Fore" .. tag, 16, 2.6, 2.6, BLACK)
	joint("Fore" .. tag, hum, fore, C(s * 7, 0, 0), C(-s * 8, 0, 0))
	deco(fore, 2.2, 7, 2.2, GOLD, C(s * 8.5, 3, 0) * CFrame.Angles(0, 0, -s * 0.3))

	local hh = { 10, 12, 12, 9 }
	for i, xo in ipairs({ -4.5, -1.5, 1.5, 4.5 }) do
		strip(hum, xo, 3.2, hh[i], REST_H, s, (i % 2 == 1) and RED or DARK_RED)
	end
	local fh = { 18, 16, 13, 9 }
	for i, xo in ipairs({ -6, -2, 2, 6 }) do
		strip(fore, xo, 3.8, fh[i], REST_F, s, (i % 2 == 1) and DARK_RED or RED)
	end
end

---------------------------------------------------------------- TIGA LEHER PANJANG (5 ruas) + KEPALA
local NSEG = { 5, 5, 5 }
local LEAN = { -0.6, -0.3, -0.1, 0.2, 0.3 }   -- lengkung S: maju lalu naik sedikit
local HEADCFG = {
	{ x = -7, roll = 0.45, yaw = 0.25 },
	{ x = 0, roll = 0, yaw = 0 },
	{ x = 7, roll = -0.45, yaw = -0.25 },
}
local NL = 6
local heads = {}

for k = 1, 3 do
	local cfg = HEADCFG[k]
	local prev = root
	for i = 1, NSEG[k] do
		local w = 7.6 - i * 0.4
		local seg = newPart("Neck" .. k .. "_" .. i, w, NL, w, BLACK)
		if i == 1 then
			joint("N" .. k .. "_1", root, seg, C(cfg.x, 5.5, -3) * CFrame.Angles(0, 0, cfg.roll), C(0, -NL / 2, 0))
		else
			joint("N" .. k .. "_" .. i, prev, seg, C(0, NL / 2, 0), C(0, -NL / 2, 0))
		end
		local gold = (i % 2 == 1)
		deco(seg, w * 0.8, NL * 0.8, 0.8, gold and GOLD or RED, C(0, 0, -(w / 2 + 0.3)))
		deco(seg, 1.2, 1.6, 2, GOLD, C(0, 0, w / 2 + 0.8))
		prev = seg
	end

	local head = newPart("Head" .. k, 7, 5, 10, BLACK)
	joint("Head" .. k, prev, head, C(0, NL / 2, 0) * CFrame.Angles(0, cfg.yaw, 0), C(0, -1.8, 4.2))
	deco(head, 7.3, 1.2, 8.5, GOLD, C(0, 3, -0.5))
	deco(head, 5.5, 3.4, 4, GOLD, C(0, -0.4, -6.8))
	for _, s in ipairs({ -1, 1 }) do
		deco(head, 1, 1, 2, EYE, C(s * 3.1, 1.2, -3))
		deco(head, 1.3, 1.3, 6, GOLD, C(s * 2.4, 2.2, 5.5) * CFrame.Angles(0.45, s * 0.25, 0))
	end
	deco(head, 1.2, 5, 1.2, GOLD, C(0, 6, 1.5))

	local jaw = newPart("Jaw" .. k, 5.6, 1.4, 13, GOLD)
	joint("Jaw" .. k, head, jaw, C(0, -2.9, 4), C(0, 0, 6.5))
	for _, s in ipairs({ -1, 1 }) do
		deco(jaw, 0.9, 1.5, 0.9, WHITE, C(s * 1.5, 1.1, -5.8))
	end

	local att = Instance.new("Attachment")
	att.Position = V(0, -1, -9.3)
	att.Parent = head

	local em = Instance.new("ParticleEmitter")
	em.Texture = "rbxasset://textures/particles/fire_main.dds"
	em.Color = ColorSequence.new(Color3.fromRGB(255, 210, 70), Color3.fromRGB(255, 50, 0))
	em.Size = NumberSequence.new({
		NumberSequenceKeypoint.new(0, 3 * S),
		NumberSequenceKeypoint.new(1, 10 * S),
	})
	em.Transparency = NumberSequence.new({
		NumberSequenceKeypoint.new(0, 0),
		NumberSequenceKeypoint.new(0.7, 0.4),
		NumberSequenceKeypoint.new(1, 1),
	})
	em.Lifetime = NumberRange.new(0.9, 1.1)
	em.Speed = NumberRange.new(80 * S, 100 * S)          -- api menjangkau sekitar 100 stud
	em.SpreadAngle = Vector2.new(10, 10)
	em.Rate = 30
	em.LightEmission = 1
	em.Acceleration = Vector3.new(0, 6, 0)
	em.EmissionDirection = Enum.NormalId.Front
	em.Enabled = false
	em.Parent = att

	heads[k] = { head = head, jaw = jaw, em = em }
end

---------------------------------------------------------------- SUARA
local roarSound = Instance.new("Sound")
roarSound.Name = "Roar"
if ROAR_SOUND_ID ~= "" and ROAR_SOUND_ID ~= "rbxassetid://0" then
	roarSound.SoundId = ROAR_SOUND_ID                    -- ID kosong/0 dilewati supaya Output tidak merah
end
roarSound.Volume = ROAR_VOLUME
roarSound.RollOffMode = Enum.RollOffMode.InverseTapered
roarSound.RollOffMaxDistance = 450
roarSound.Parent = root

---------------------------------------------------------------- POSISI AWAL
local groundY = place.Position.Y + place.Size.Y / 2
local basePos = Vector3.new(place.Position.X, groundY + 15.8 * S, place.Position.Z)
local facingRot = place.CFrame.Rotation
model.Parent = Workspace
model:PivotTo(CFrame.new(basePos) * facingRot)

---------------------------------------------------------------- ANIMASI
local W = { walk = 0, fly = 0, roar = 0, fire = 0 }
local T = { walk = 0, fly = 0, roar = 0, fire = 0 }
local biteT = nil
local faceTarget = nil

local function setRot(name, cf)
	local j = J[name]
	j.m.C0 = j.base * cf
end

local function update(dt, t)
	for k, v in pairs(W) do
		local rate = (k == "fly") and 2 or 5
		W[k] = v + (T[k] - v) * math.min(1, dt * rate)
	end

	for k = 1, 3 do
		local lunge, jawBite = 0, 0
		if biteT then
			local x = (t - biteT) - (k - 1) * 0.35
			if x > 0 and x < 0.6 then
				lunge = math.sin(x / 0.6 * math.pi)
				jawBite = (x < 0.3) and (x / 0.3) or math.max(0, 1 - (x - 0.3) / 0.15)
			end
		end
		local inward = -math.sign(HEADCFG[k].roll) * 0.08
		for i = 1, NSEG[k] do
			local ph = t * 1.3 + k * 1.7 + i * 0.45
			local rx = LEAN[i] + math.sin(ph) * 0.04
			rx = rx + W.roar * 0.1 - W.fire * 0.08 - lunge * 0.2
			local ry = math.cos(ph * 0.8) * 0.06 * (1 - W.fire * 0.8) + math.sin(t * 2 + k) * 0.05 * W.fire
			local rz = (i > 1) and inward or 0
			setRot("N" .. k .. "_" .. i, CFrame.Angles(rx, ry, rz))
		end
		setRot("Head" .. k, CFrame.Angles(0.4 + W.roar * 0.6 - W.fire * 0.25 - lunge * 0.3, 0, 0))
		local open = 0.1 + W.roar * 0.7 * (0.9 + 0.1 * math.sin(t * 14)) + W.fire * 0.5 + jawBite * 0.9
		setRot("Jaw" .. k, CFrame.Angles(-open, 0, 0))
	end

	local p = t * 3.2
	for idx, tag in ipairs({ "L", "R" }) do
		local ph = p + ((idx == 2) and math.pi or 0)
		local thigh = math.sin(ph) * 0.4 * W.walk - 0.5 * W.fly
		local knee = -(0.04 + math.max(0, math.cos(ph)) * 0.6 * W.walk + 0.7 * W.fly)
		setRot("Thigh" .. tag, CFrame.Angles(thigh, 0, 0))
		setRot("Shin" .. tag, CFrame.Angles(knee, 0, 0))
		setRot("Foot" .. tag, CFrame.Angles(-(thigh + knee), 0, 0))
	end

	for i = 1, NT do
		local amp = 0.08 + 0.07 * W.walk + 0.08 * W.fly + 0.07 * W.roar
		setRot("Tail" .. i, CFrame.Angles(-0.04, 0.1 + math.sin(t * 1.6 - i * 0.5) * amp, 0))
	end

	local flap = math.sin(t * 5)
	local idle = math.sin(t * 1.2) * 0.05
	for _, s in ipairs({ -1, 1 }) do
		local tag = (s < 0) and "L" or "R"
		local sh = REST_H + idle * (1 - W.fly) + W.fly * flap * 0.7 + W.roar * 0.3 + W.fire * 0.1
		local el = (REST_F - REST_H) + W.fly * math.sin(t * 5 - 0.9) * 0.4 + idle * 0.5
		setRot("Hum" .. tag, CFrame.Angles(math.sin(t * 5 + 1) * 0.1 * W.fly, 0, s * sh))
		setRot("Fore" .. tag, CFrame.Angles(0, 0, s * el))
	end

	if FACE_PLAYER and faceTarget then
		local dir = Vector3.new(faceTarget.X - basePos.X, 0, faceTarget.Z - basePos.Z)
		if dir.Magnitude > 1 then
			local desired = CFrame.lookAt(Vector3.zero, dir.Unit)
			facingRot = facingRot:Lerp(desired, math.min(1, dt * 1.5))
		end
	end
	local hover = W.fly * (FLY_HEIGHT + math.sin(t * 2.2) * 1.2) * S
	local bob = math.abs(math.sin(p)) * 0.7 * S * W.walk
	local roll = math.sin(p) * 0.025 * W.walk
	root.CFrame = CFrame.new(basePos + Vector3.new(0, hover + bob, 0))
		* facingRot * CFrame.Angles(-W.fly * 0.08, 0, roll)
end

local acc = 0
local conn
conn = RunService.Heartbeat:Connect(function(dt)
	if not model.Parent then
		conn:Disconnect()
		return
	end
	acc += dt
	if acc < 1 / ANIM_FPS then return end
	local step = acc
	acc = 0
	update(step, os.clock())
end)

---------------------------------------------------------------- DAMAGE
local function eachTarget(fn)
	for _, plr in ipairs(Players:GetPlayers()) do
		local ch = plr.Character
		local hrp = ch and ch:FindFirstChild("HumanoidRootPart")
		local hum = ch and ch:FindFirstChildOfClass("Humanoid")
		if hrp and hum and hum.Health > 0 then
			fn(hrp, hum)
		end
	end
end

local function nearest()
	local best, bestD = nil, math.huge
	eachTarget(function(hrp)
		local d = Vector3.new(hrp.Position.X - basePos.X, 0, hrp.Position.Z - basePos.Z).Magnitude
		if d < bestD then best, bestD = hrp, d end
	end)
	return best, bestD
end

---------------------------------------------------------------- AKSI
local function doIdle(dur) task.wait(dur) end

local function doWalk(dur)
	T.walk = 1
	task.wait(dur)
	T.walk = 0
	task.wait(0.4)
end

local function doFly(dur)
	T.fly = 1
	task.wait(dur)
	T.fly = 0
	task.wait(2.2)
end

local function doRoar()
	T.roar = 1
	task.wait(0.4)
	if roarSound.SoundId ~= "" then roarSound:Play() end
	task.wait(2.4)
	T.roar = 0
	task.wait(0.6)
end

local function doBite()
	biteT = os.clock()
	for k = 1, 3 do
		task.delay((k - 1) * 0.35 + 0.45, function()
			if not model.Parent then return end
			local hp = heads[k].head.Position
			eachTarget(function(hrp, hum)
				local d = Vector3.new(hrp.Position.X - hp.X, 0, hrp.Position.Z - hp.Z).Magnitude
				if d <= BITE_RANGE * S and hum.Health > 0 then
					hum:TakeDamage(BITE_DAMAGE)
				end
			end)
		end)
	end
	task.wait(1.6)
	biteT = nil
	task.wait(0.4)
end

local function doFire()
	T.fire = 1
	task.wait(0.5)
	for _, h in ipairs(heads) do h.em.Enabled = true end
	local t0 = os.clock()
	while os.clock() - t0 < FIRE_DURATION and model.Parent do
		local hit = {}
		for _, h in ipairs(heads) do
			local origin = h.head.Position
			local look = h.head.CFrame.LookVector
			eachTarget(function(hrp, hum)
				if not hit[hum] then
					local v = hrp.Position - origin
					local d = v.Magnitude
					if d > 0 and d <= FIRE_RANGE * S and v.Unit:Dot(look) > 0.5 then
						hit[hum] = true
						hum:TakeDamage(FIRE_DAMAGE)
					end
				end
			end)
		end
		task.wait(0.25)
	end
	for _, h in ipairs(heads) do h.em.Enabled = false end
	T.fire = 0
	task.wait(0.8)
end

---------------------------------------------------------------- AI
task.spawn(function()
	local lastFire, lastRoar = 0, 0
	while model.Parent do
		local ok, err = pcall(function()
			local hrp, d = nearest()
			faceTarget = hrp and hrp.Position or nil
			local now = os.clock()
			if hrp and d <= DETECT_RANGE * S then
				if d <= BITE_TRIGGER * S then
					doBite()
				elseif d <= FIRE_RANGE * S and now - lastFire > FIRE_COOLDOWN then
					lastFire = os.clock()
					doFire()
				elseif now - lastRoar > 12 then
					lastRoar = os.clock()
					doRoar()
				elseif math.random() < 0.15 then
					doFly(5)
				else
					doWalk(2.5)
				end
			else
				local r = math.random()
				if r < 0.35 then doIdle(3)
				elseif r < 0.6 then doWalk(4)
				elseif r < 0.8 then doRoar()
				else doFly(6) end
			end
		end)
		if not ok then warn("[Ghidorah] " .. tostring(err)) task.wait(1) end
		task.wait(0.1)
	end
end)
ScriptVersi 2
--[[
	KING GHIDORAH v8 VOID - Ungu Void + Emas + Putih (Roblox Studio Lite)
	CARA PAKAI:
	1. Part di Workspace bernama persis: GhidorahPlace (Anchored, besar, mis. 150x2x150)
	2. buat Script (BUKAN LocalScript) di ServerScriptService, paste kode ini
	3. Ganti ROAR_SOUND_ID dengan ID sound roar kamu (0 = tanpa suara, tidak error)
	4. Play. Ubah SCALE untuk membesar/mengecil.
	Baru: warna Void, emas mengkilap, halo emas di belakang, mahkota 3 tanduk di tiap kepala,
	taring putih, mata menyala, sayap tembus pandang, aura partikel void, api ungu-putih.
]]

local Players = game:GetService("Players")
local RunService = game:GetService("RunService")
local Workspace = game:GetService("Workspace")

---------------------------------------------------------------- CONFIG
local SCALE = 1
local ROAR_SOUND_ID = "rbxassetid://0"       -- <<< GANTI ID SOUND ROAR DI SINI
local ROAR_VOLUME = 4
local DETECT_RANGE = 110
local FIRE_RANGE = 100
local BITE_TRIGGER = 60
local BITE_RANGE = 45
local BITE_DAMAGE = 25
local FIRE_DAMAGE = 6
local FIRE_DURATION = 3
local FIRE_COOLDOWN = 6
local FLY_HEIGHT = 10
local ANIM_FPS = 20
local FACE_PLAYER = true

FIRE_RANGE = math.min(FIRE_RANGE, DETECT_RANGE)
BITE_TRIGGER = math.min(BITE_TRIGGER, FIRE_RANGE - 10)
BITE_RANGE = math.min(BITE_RANGE, BITE_TRIGGER)

-- PALET VOID
local VOID = Color3.fromRGB(125, 45, 210)        -- ungu void terang
local DEEP = Color3.fromRGB(70, 20, 135)         -- ungu gelap
local BLACK = Color3.fromRGB(20, 10, 34)         -- hitam keunguan
local GOLD = Color3.fromRGB(255, 205, 40)
local DARK_GOLD = Color3.fromRGB(210, 155, 15)
local WHITE = Color3.fromRGB(248, 245, 255)
local EYE = Color3.fromRGB(240, 210, 255)
local GLOW = Color3.fromRGB(170, 80, 255)
local PLASTIC = Enum.Material.Plastic

---------------------------------------------------------------- CARI PLACE
local place = Workspace:WaitForChild("GhidorahPlace", 15)
if not place or not place:IsA("BasePart") then
	warn("[Ghidorah] Part bernama 'GhidorahPlace' tidak ditemukan di Workspace!")
	return
end
local old = Workspace:FindFirstChild("Ghidorah")
if old then old:Destroy() end

---------------------------------------------------------------- HELPER BUILD
local S = SCALE
local function V(x, y, z) return Vector3.new(x * S, y * S, z * S) end
local function C(x, y, z) return CFrame.new(x * S, y * S, z * S) end

local model = Instance.new("Model")
model.Name = "Ghidorah"

local SURFACES = { "TopSurface", "BottomSurface", "LeftSurface", "RightSurface", "FrontSurface", "BackSurface" }

local function newPart(name, sx, sy, sz, color)
	local p = Instance.new("Part")
	p.Name = name
	p.Size = V(sx, sy, sz)
	p.Color = color
	p.Material = PLASTIC
	if color == GOLD or color == DARK_GOLD then p.Reflectance = 0.18 end  -- emas mengkilap
	p.Anchored = false
	p.CanCollide = false
	p.CanTouch = false
	p.CanQuery = false
	p.Massless = true
	p.CastShadow = false
	for _, sn in ipairs(SURFACES) do
		p[sn] = Enum.SurfaceType.Studs
	end
	p.Parent = model
	return p
end

local J = {}
local function joint(name, p0, p1, c0, c1)
	local m = Instance.new("Motor6D")
	m.Name = name
	m.Part0 = p0
	m.Part1 = p1
	m.C0 = c0
	m.C1 = c1 or CFrame.new()
	m.Parent = p0
	p1.CFrame = p0.CFrame * c0 * m.C1:Inverse()
	J[name] = { m = m, base = c0 }
	return m
end

local decoCount = 0
local function deco(parent, sx, sy, sz, color, c0, neon)
	decoCount += 1
	local name = "D" .. decoCount
	local p = newPart(name, sx, sy, sz, color)
	if neon then p.Material = Enum.Material.Neon end
	joint(name, parent, p, c0)
	return p
end

---------------------------------------------------------------- TORSO TUMPUKAN STUD
local root = newPart("Body", 22, 10, 16, BLACK)
root.Anchored = true
root.CFrame = CFrame.new()
model.PrimaryPart = root

local LW = { 20, 27, 31, 30, 26, 20 }
local LD = { 14, 19, 22, 21, 18, 14 }
for i = 1, 6 do
	local y = -5 + (i - 1) * 2.4
	local w, d = LW[i], LD[i]
	local even = (i % 2 == 0)
	deco(root, w - 6.4, 2.3, d, even and VOID or BLACK, C(0, y, 0))
	for _, s in ipairs({ -1, 1 }) do
		deco(root, 3.3, 2.3, d - 1, even and GOLD or DEEP, C(s * (w / 2 - 1.65), y, 0))
	end
end

-- perut: dinding brick emas/putih
for ix = -1, 1 do
	for iy = 0, 1 do
		local c = ((ix + iy) % 2 == 0) and GOLD or WHITE
		deco(root, 4, 2.6, 3.5, c, C(ix * 4.2, -3.6 + iy * 2.8, -10.8))
	end
end

-- dada + permata void bercahaya
for _, s in ipairs({ -1, 1 }) do
	for iy = 0, 1 do
		deco(root, 5, 2.6, 3, (iy == 0) and GOLD or VOID, C(s * 5.6, 3.4 + iy * 2.8, -10.4))
	end
end
deco(root, 6, 6, 2, GOLD, C(0, 4.8, -10))
local gem = deco(root, 3.6, 3.6, 1.6, GLOW, C(0, 4.8, -11.4), true)
local gl = Instance.new("PointLight")
gl.Color = GLOW
gl.Brightness = 3
gl.Range = 22
gl.Parent = gem

deco(root, 16, 1.6, 10, GOLD, C(0, 8.8, -3))  -- kerah

-- punggung + duri
for i = 0, 2 do
	deco(root, 17 - i * 2.5, 2.4, 2.6, (i == 1) and VOID or BLACK, C(0, -2 + i * 3, 11.9))
end
for i = 0, 2 do
	deco(root, 3, 4, 3.4, (i == 1) and WHITE or GOLD, C(0, 4.6 - i * 3.2, 14.2))
end

-- bahu 3 tingkat + tanduk
for _, s in ipairs({ -1, 1 }) do
	deco(root, 8, 2.6, 10, GOLD, C(s * 14.5, 3.6, 0))
	deco(root, 6.4, 2.2, 8.4, BLACK, C(s * 14.5, 5.6, 0))
	deco(root, 4.6, 2, 6.4, GOLD, C(s * 14.5, 7.4, 0))
	deco(root, 2, 6, 2, WHITE, C(s * 15, 11.2, -1) * CFrame.Angles(0, 0, -s * 0.3))
end

-- HALO EMAS di belakang badan (lingkaran, tanpa bagian bawah supaya tidak menabrak ekor)
for i = 0, 11 do
	local a = i / 12 * math.pi * 2
	if math.sin(a) > -0.4 then
		deco(root, 4.4, 1.6, 1.6, (i % 2 == 0) and GOLD or WHITE,
			C(math.cos(a) * 15, 6 + math.sin(a) * 15, 17) * CFrame.Angles(0, 0, a + math.pi / 2), i % 2 == 1)
	end
end

---------------------------------------------------------------- KAKI
for _, s in ipairs({ -1, 1 }) do
	local tag = (s < 0) and "L" or "R"
	local thigh = newPart("Thigh" .. tag, 10, 5, 10, BLACK)
	joint("Thigh" .. tag, root, thigh, C(s * 8, -4, 0), C(0, 2.5, 0))
	deco(thigh, 11, 2, 11, VOID, C(0, 1.2, 0))
	deco(thigh, 6, 3, 2, GOLD, C(0, -0.5, -5.6))

	local shin = newPart("Shin" .. tag, 9, 4, 9, BLACK)
	joint("Shin" .. tag, thigh, shin, C(0, -2.5, 0), C(0, 2, 0))
	deco(shin, 10, 1.4, 10, GOLD, C(0, -0.8, 0))
	deco(shin, 5, 2, 2, WHITE, C(0, 0.4, -5))

	local foot = newPart("Foot" .. tag, 11, 2.5, 13, BLACK)
	joint("Foot" .. tag, shin, foot, C(0, -2, 0), C(0, 1.25, 2))
	for i = -1, 1 do
		deco(foot, 2.8, 2.2, 4.5, WHITE, C(i * 3.6, 0, -8.4))  -- cakar putih
	end
end

---------------------------------------------------------------- EKOR
local NT = 6
do
	local prev = root
	local TL = 8
	for i = 1, NT do
		local w, h = math.max(3.6, 14 - i * 1.7), math.max(3, 9 - i * 1)
		local seg = newPart("Tail" .. i, w, h, TL, (i % 2 == 1) and BLACK or VOID)
		if i == 1 then
			joint("Tail1", root, seg, C(0, -3, 8), C(0, 0, -TL / 2))
		else
			joint("Tail" .. i, prev, seg, C(0, 0, TL / 2), C(0, 0, -TL / 2))
		end
		deco(seg, 1.8, math.max(2, 4 - i * 0.3), 3, GOLD, C(0, h / 2 + 1.2, 0))
		deco(seg, w * 0.6, 1, TL - 0.6, GOLD, C(0, -h / 2 - 0.4, 0))
		if i == NT then
			deco(seg, 2.4, 2.4, 6, GLOW, C(0, 0, TL / 2 + 2.5), true)
		end
		prev = seg
	end
end

---------------------------------------------------------------- SAYAP (tembus pandang)
local REST_H, REST_F = 0.85, 0.5
local function strip(parent, xo, w, h, rest, s, color)
	decoCount += 1
	local name = "D" .. decoCount
	local p = newPart(name, w, h, 0.5, color)
	p.Transparency = 0.2
	joint(name, parent, p, C(xo, 0, 0) * CFrame.Angles(0, 0, -s * rest) * C(0, -h / 2 - 0.5, 0))
	return p
end

for _, s in ipairs({ -1, 1 }) do
	local tag = (s < 0) and "L" or "R"
	local hum = newPart("Hum" .. tag, 14, 3, 3, BLACK)
	joint("Hum" .. tag, root, hum, C(s * 13, 4, 6), C(-s * 7, 0, 0))
	deco(hum, 14, 1.3, 1.3, GOLD, C(0, 2, 0))

	local fore = newPart("Fore" .. tag, 16, 2.6, 2.6, BLACK)
	joint("Fore" .. tag, hum, fore, C(s * 7, 0, 0), C(-s * 8, 0, 0))
	deco(fore, 2.2, 7, 2.2, WHITE, C(s * 8.5, 3, 0) * CFrame.Angles(0, 0, -s * 0.3))

	local hh = { 10, 12, 12, 9 }
	for i, xo in ipairs({ -4.5, -1.5, 1.5, 4.5 }) do
		strip(hum, xo, 3.2, hh[i], REST_H, s, (i % 2 == 1) and VOID or DEEP)
	end
	local fh = { 18, 16, 13, 9 }
	for i, xo in ipairs({ -6, -2, 2, 6 }) do
		strip(fore, xo, 3.8, fh[i], REST_F, s, (i % 2 == 1) and DEEP or VOID)
	end
end

---------------------------------------------------------------- TIGA LEHER + KEPALA
local NSEG = { 5, 5, 5 }
local LEAN = { -0.6, -0.3, -0.1, 0.2, 0.3 }
local HEADCFG = {
	{ x = -7, roll = 0.45, yaw = 0.25 },
	{ x = 0, roll = 0, yaw = 0 },
	{ x = 7, roll = -0.45, yaw = -0.25 },
}
local NL = 6
local heads = {}

for k = 1, 3 do
	local cfg = HEADCFG[k]
	local prev = root
	for i = 1, NSEG[k] do
		local w = 7.6 - i * 0.4
		local seg = newPart("Neck" .. k .. "_" .. i, w, NL, w, BLACK)
		if i == 1 then
			joint("N" .. k .. "_1", root, seg, C(cfg.x, 5.5, -3) * CFrame.Angles(0, 0, cfg.roll), C(0, -NL / 2, 0))
		else
			joint("N" .. k .. "_" .. i, prev, seg, C(0, NL / 2, 0), C(0, -NL / 2, 0))
		end
		local gold = (i % 2 == 1)
		deco(seg, w * 0.8, NL * 0.8, 0.8, gold and GOLD or VOID, C(0, 0, -(w / 2 + 0.3)))
		deco(seg, 1.2, 1.6, 2, WHITE, C(0, 0, w / 2 + 0.8))
		prev = seg
	end

	local head = newPart("Head" .. k, 7, 5, 10, BLACK)
	joint("Head" .. k, prev, head, C(0, NL / 2, 0) * CFrame.Angles(0, cfg.yaw, 0), C(0, -1.8, 4.2))
	deco(head, 7.3, 1.2, 8.5, GOLD, C(0, 3, -0.5))
	deco(head, 5.5, 3.4, 4, GOLD, C(0, -0.4, -6.8))
	for _, s in ipairs({ -1, 1 }) do
		deco(head, 1, 1, 2, EYE, C(s * 3.1, 1.2, -3), true)                       -- mata menyala
		deco(head, 1.3, 1.3, 6, GOLD, C(s * 2.4, 2.2, 5.5) * CFrame.Angles(0.45, s * 0.25, 0))
		deco(head, 0.9, 1.6, 0.9, WHITE, C(s * 1.8, -2.4, -8.4))                  -- taring atas
	end
	-- mahkota 3 tanduk
	deco(head, 1.2, 5.5, 1.2, WHITE, C(0, 6, 1.5))
	for _, s in ipairs({ -1, 1 }) do
		deco(head, 1, 3.6, 1, GOLD, C(s * 1.6, 5, 1.5) * CFrame.Angles(0, 0, -s * 0.35))
	end

	local jaw = newPart("Jaw" .. k, 5.6, 1.4, 13, GOLD)
	joint("Jaw" .. k, head, jaw, C(0, -2.9, 4), C(0, 0, 6.5))
	for _, s in ipairs({ -1, 1 }) do
		deco(jaw, 0.9, 1.5, 0.9, WHITE, C(s * 1.5, 1.1, -5.8))
	end

	local att = Instance.new("Attachment")
	att.Position = V(0, -1, -9.3)
	att.Parent = head

	local em = Instance.new("ParticleEmitter")
	em.Texture = "rbxasset://textures/particles/fire_main.dds"
	em.Color = ColorSequence.new({
		ColorSequenceKeypoint.new(0, WHITE),
		ColorSequenceKeypoint.new(0.4, GLOW),
		ColorSequenceKeypoint.new(1, Color3.fromRGB(70, 10, 150)),
	})
	em.Size = NumberSequence.new({
		NumberSequenceKeypoint.new(0, 3 * S),
		NumberSequenceKeypoint.new(1, 10 * S),
	})
	em.Transparency = NumberSequence.new({
		NumberSequenceKeypoint.new(0, 0),
		NumberSequenceKeypoint.new(0.7, 0.4),
		NumberSequenceKeypoint.new(1, 1),
	})
	em.Lifetime = NumberRange.new(0.9, 1.1)
	em.Speed = NumberRange.new(80 * S, 100 * S)
	em.SpreadAngle = Vector2.new(10, 10)
	em.Rate = 30
	em.LightEmission = 1
	em.Acceleration = Vector3.new(0, 6, 0)
	em.EmissionDirection = Enum.NormalId.Front
	em.Enabled = false
	em.Parent = att

	heads[k] = { head = head, jaw = jaw, em = em }
end

---------------------------------------------------------------- AURA VOID
do
	local aura = Instance.new("ParticleEmitter")
	aura.Texture = "rbxasset://textures/particles/sparkles_main.dds"
	aura.Color = ColorSequence.new(GLOW, WHITE)
	aura.Size = NumberSequence.new(1.5 * S, 0)
	aura.Transparency = NumberSequence.new(0.2, 1)
	aura.Lifetime = NumberRange.new(1.5, 2.5)
	aura.Speed = NumberRange.new(3, 8)
	aura.SpreadAngle = Vector2.new(180, 180)
	aura.Rate = 14
	aura.LightEmission = 1
	aura.Parent = root
	local pl = Instance.new("PointLight")
	pl.Color = GLOW
	pl.Brightness = 1.5
	pl.Range = 40
	pl.Parent = root
end

---------------------------------------------------------------- SUARA
local roarSound = Instance.new("Sound")
roarSound.Name = "Roar"
if ROAR_SOUND_ID ~= "" and ROAR_SOUND_ID ~= "rbxassetid://0" then
	roarSound.SoundId = ROAR_SOUND_ID
end
roarSound.Volume = ROAR_VOLUME
roarSound.RollOffMode = Enum.RollOffMode.InverseTapered
roarSound.RollOffMaxDistance = 450
roarSound.Parent = root

---------------------------------------------------------------- POSISI AWAL
local groundY = place.Position.Y + place.Size.Y / 2
local basePos = Vector3.new(place.Position.X, groundY + 15.8 * S, place.Position.Z)
local facingRot = place.CFrame.Rotation
model.Parent = Workspace
model:PivotTo(CFrame.new(basePos) * facingRot)

---------------------------------------------------------------- ANIMASI
local W = { walk = 0, fly = 0, roar = 0, fire = 0 }
local T = { walk = 0, fly = 0, roar = 0, fire = 0 }
local biteT = nil
local faceTarget = nil

local function setRot(name, cf)
	local j = J[name]
	j.m.C0 = j.base * cf
end

local function update(dt, t)
	for k, v in pairs(W) do
		local rate = (k == "fly") and 2 or 5
		W[k] = v + (T[k] - v) * math.min(1, dt * rate)
	end

	for k = 1, 3 do
		local lunge, jawBite = 0, 0
		if biteT then
			local x = (t - biteT) - (k - 1) * 0.35
			if x > 0 and x < 0.6 then
				lunge = math.sin(x / 0.6 * math.pi)
				jawBite = (x < 0.3) and (x / 0.3) or math.max(0, 1 - (x - 0.3) / 0.15)
			end
		end
		local inward = -math.sign(HEADCFG[k].roll) * 0.08
		for i = 1, NSEG[k] do
			local ph = t * 1.3 + k * 1.7 + i * 0.45
			local rx = LEAN[i] + math.sin(ph) * 0.04
			rx = rx + W.roar * 0.1 - W.fire * 0.08 - lunge * 0.2
			local ry = math.cos(ph * 0.8) * 0.06 * (1 - W.fire * 0.8) + math.sin(t * 2 + k) * 0.05 * W.fire
			local rz = (i > 1) and inward or 0
			setRot("N" .. k .. "_" .. i, CFrame.Angles(rx, ry, rz))
		end
		setRot("Head" .. k, CFrame.Angles(0.4 + W.roar * 0.6 - W.fire * 0.25 - lunge * 0.3, 0, 0))
		local open = 0.1 + W.roar * 0.7 * (0.9 + 0.1 * math.sin(t * 14)) + W.fire * 0.5 + jawBite * 0.9
		setRot("Jaw" .. k, CFrame.Angles(-open, 0, 0))
	end

	local p = t * 3.2
	for idx, tag in ipairs({ "L", "R" }) do
		local ph = p + ((idx == 2) and math.pi or 0)
		local thigh = math.sin(ph) * 0.4 * W.walk - 0.5 * W.fly
		local knee = -(0.04 + math.max(0, math.cos(ph)) * 0.6 * W.walk + 0.7 * W.fly)
		setRot("Thigh" .. tag, CFrame.Angles(thigh, 0, 0))
		setRot("Shin" .. tag, CFrame.Angles(knee, 0, 0))
		setRot("Foot" .. tag, CFrame.Angles(-(thigh + knee), 0, 0))
	end

	for i = 1, NT do
		local amp = 0.08 + 0.07 * W.walk + 0.08 * W.fly + 0.07 * W.roar
		setRot("Tail" .. i, CFrame.Angles(-0.04, 0.1 + math.sin(t * 1.6 - i * 0.5) * amp, 0))
	end

	local flap = math.sin(t * 5)
	local idle = math.sin(t * 1.2) * 0.05
	for _, s in ipairs({ -1, 1 }) do
		local tag = (s < 0) and "L" or "R"
		local sh = REST_H + idle * (1 - W.fly) + W.fly * flap * 0.7 + W.roar * 0.3 + W.fire * 0.1
		local el = (REST_F - REST_H) + W.fly * math.sin(t * 5 - 0.9) * 0.4 + idle * 0.5
		setRot("Hum" .. tag, CFrame.Angles(math.sin(t * 5 + 1) * 0.1 * W.fly, 0, s * sh))
		setRot("Fore" .. tag, CFrame.Angles(0, 0, s * el))
	end

	if FACE_PLAYER and faceTarget then
		local dir = Vector3.new(faceTarget.X - basePos.X, 0, faceTarget.Z - basePos.Z)
		if dir.Magnitude > 1 then
			local desired = CFrame.lookAt(Vector3.zero, dir.Unit)
			facingRot = facingRot:Lerp(desired, math.min(1, dt * 1.5))
		end
	end
	local hover = W.fly * (FLY_HEIGHT + math.sin(t * 2.2) * 1.2) * S
	local bob = math.abs(math.sin(p)) * 0.7 * S * W.walk
	local roll = math.sin(p) * 0.025 * W.walk
	root.CFrame = CFrame.new(basePos + Vector3.new(0, hover + bob, 0))
		* facingRot * CFrame.Angles(-W.fly * 0.08, 0, roll)
end

local acc = 0
local conn
conn = RunService.Heartbeat:Connect(function(dt)
	if not model.Parent then
		conn:Disconnect()
		return
	end
	acc += dt
	if acc < 1 / ANIM_FPS then return end
	local step = acc
	acc = 0
	update(step, os.clock())
end)

---------------------------------------------------------------- DAMAGE
local function eachTarget(fn)
	for _, plr in ipairs(Players:GetPlayers()) do
		local ch = plr.Character
		local hrp = ch and ch:FindFirstChild("HumanoidRootPart")
		local hum = ch and ch:FindFirstChildOfClass("Humanoid")
		if hrp and hum and hum.Health > 0 then
			fn(hrp, hum)
		end
	end
end

local function nearest()
	local best, bestD = nil, math.huge
	eachTarget(function(hrp)
		local d = Vector3.new(hrp.Position.X - basePos.X, 0, hrp.Position.Z - basePos.Z).Magnitude
		if d < bestD then best, bestD = hrp, d end
	end)
	return best, bestD
end

---------------------------------------------------------------- AKSI
local function doIdle(dur) task.wait(dur) end

local function doWalk(dur)
	T.walk = 1
	task.wait(dur)
	T.walk = 0
	task.wait(0.4)
end

local function doFly(dur)
	T.fly = 1
	task.wait(dur)
	T.fly = 0
	task.wait(2.2)
end

local function doRoar()
	T.roar = 1
	task.wait(0.4)
	if roarSound.SoundId ~= "" then roarSound:Play() end
	task.wait(2.4)
	T.roar = 0
	task.wait(0.6)
end

local function doBite()
	biteT = os.clock()
	for k = 1, 3 do
		task.delay((k - 1) * 0.35 + 0.45, function()
			if not model.Parent then return end
			local hp = heads[k].head.Position
			eachTarget(function(hrp, hum)
				local d = Vector3.new(hrp.Position.X - hp.X, 0, hrp.Position.Z - hp.Z).Magnitude
				if d <= BITE_RANGE * S and hum.Health > 0 then
					hum:TakeDamage(BITE_DAMAGE)
				end
			end)
		end)
	end
	task.wait(1.6)
	biteT = nil
	task.wait(0.4)
end

local function doFire()
	T.fire = 1
	task.wait(0.5)
	for _, h in ipairs(heads) do h.em.Enabled = true end
	local t0 = os.clock()
	while os.clock() - t0 < FIRE_DURATION and model.Parent do
		local hit = {}
		for _, h in ipairs(heads) do
			local origin = h.head.Position
			local look = h.head.CFrame.LookVector
			eachTarget(function(hrp, hum)
				if not hit[hum] then
					local v = hrp.Position - origin
					local d = v.Magnitude
					if d > 0 and d <= FIRE_RANGE * S and v.Unit:Dot(look) > 0.5 then
						hit[hum] = true
						hum:TakeDamage(FIRE_DAMAGE)
					end
				end
			end)
		end
		task.wait(0.25)
	end
	for _, h in ipairs(heads) do h.em.Enabled = false end
	T.fire = 0
	task.wait(0.8)
end

---------------------------------------------------------------- AI
task.spawn(function()
	local lastFire, lastRoar = 0, 0
	while model.Parent do
		local ok, err = pcall(function()
			local hrp, d = nearest()
			faceTarget = hrp and hrp.Position or nil
			local now = os.clock()
			if hrp and d <= DETECT_RANGE * S then
				if d <= BITE_TRIGGER * S then
					doBite()
				elseif d <= FIRE_RANGE * S and now - lastFire > FIRE_COOLDOWN then
					lastFire = os.clock()
					doFire()
				elseif now - lastRoar > 12 then
					lastRoar = os.clock()
					doRoar()
				elseif math.random() < 0.15 then
					doFly(5)
				else
					doWalk(2.5)
				end
			else
				local r = math.random()
				if r < 0.35 then doIdle(3)
				elseif r < 0.6 then doWalk(4)
				elseif r < 0.8 then doRoar()
				else doFly(6) end
			end
		end)
		if not ok then warn("[Ghidorah] " .. tostring(err)) task.wait(1) end
		task.wait(0.1)
	end
end)