← KEMBALI KE SCRIPT LIBRARY

Musuh Gurita (Octopus enemy)

UmumVersi 1.0Update 25/11/2026

BOSS GURITA STUD 3D PREMIUM

Cara penggunaan
Full Tutorial di YouTube iBalDBK
Lokasi pemasangan
ServerScriptService
ScriptServerScriptService
--[[ BOSS GURITA STUD 3D PREMIUM
Letakkan: ServerScriptService > Script (bukan LocalScript)
Wajib ada Part bernama "GuritaPlace" (Anchored) di Workspace. ]]

local Players = game:GetService("Players")
local RS = game:GetService("RunService")
local TweenService = game:GetService("TweenService")
local Debris = game:GetService("Debris")

-- ================== PENGATURAN ==================
local Config = {
	PlaceName = "GuritaPlace",
	MoveSpeed = 14,          -- kecepatan gerak
	DetectRange = 70,        -- jarak deteksi pemain
	AttackRange = 12,        -- jarak pukulan tentakel
	ShootRange = 55,         -- jarak tembakan
	MeleeDamage = 25,        -- damage pukulan
	ShootDamage = 15,        -- damage tembakan
	ProjectileSpeed = 70,    -- kecepatan proyektil
	ProjectileSize = 2.2,
	ProjectileRange = 100,
	MeleeCooldown = 2.5,     -- cooldown pukul (detik)
	ShootCooldown = 4,       -- cooldown tembak (detik)
	BodyColor = Color3.fromRGB(240, 236, 248),   -- putih
	AccentColor = Color3.fromRGB(95, 25, 190),   -- ungu
	GoldColor = Color3.fromRGB(255, 190, 30),    -- emas
	VoidColor = Color3.fromRGB(70, 0, 130),      -- warna efek Void
	BodyScale = 1,           -- ukuran tubuh
	TentacleScale = 1,       -- ukuran tentakel
	AnimSpeed = 1,           -- kecepatan animasi
	TurnSpeed = 6,
	VoidSlowMult = 0.5,      -- efek Void: pemain melambat
	VoidSlowTime = 1.5,
	SwingSound = "rbxasset://sounds/swordslash.wav",
	ShootSound = "rbxasset://sounds/impact_water.mp3",
	ChargeSound = "rbxasset://sounds/electronicpingshort.wav",
	HitSound = "rbxasset://sounds/impact_water.mp3",
}
-- ================================================

local C, S, TSC = Config, Config.BodyScale, Config.TentacleScale
local place = workspace:WaitForChild(C.PlaceName, 20)
if not place or not place:IsA("BasePart") then
	warn("[Gurita] Part '" .. C.PlaceName .. "' tidak ditemukan!")
	return
end

-- cegah duplikasi
for _, n in ipairs({ "GuritaBoss", "GuritaFX" }) do
	local o = workspace:FindFirstChild(n)
	if o then o:Destroy() end
end
local fxFolder = Instance.new("Folder")
fxFolder.Name = "GuritaFX"
fxFolder.Parent = workspace
local model = Instance.new("Model")
model.Name = "GuritaBoss"

-- ============ BUILDER ============
local SURF = { "Top", "Bottom", "Left", "Right", "Front", "Back" }
local function V(x, y, z) return Vector3.new(x, y, z) * S end

local function mk(size, cf, col, o)
	o = o or {}
	local p = Instance.new("Part")
	p.Size, p.CFrame, p.Color = size, cf, col
	p.Material = o.neon and Enum.Material.Neon or Enum.Material.Plastic
	p.Anchored, p.CanCollide, p.CanQuery, p.CanTouch = false, false, false, false
	p.Massless, p.CastShadow = true, false
	if o.round then
		local m = Instance.new("SpecialMesh")
		m.MeshType = Enum.MeshType.Sphere
		m.Parent = p
	elseif not o.plain then
		for _, s in ipairs(SURF) do p[s .. "Surface"] = Enum.SurfaceType.Studs end -- tekstur Stud
	end
	if o.hide then p.Transparency = 1 end
	p.Parent = model
	return p
end

local function weld(a, b)
	local w = Instance.new("Weld")
	w.Part0, w.Part1, w.C0 = a, b, a.CFrame:Inverse() * b.CFrame
	w.Parent = a
end

local root = mk(V(1, 1, 1), CFrame.new(), C.BodyColor, { plain = true, hide = true })
root.Anchored = true
model.PrimaryPart = root
local upper = mk(V(1, 1, 1), CFrame.new(), C.BodyColor, { plain = true, hide = true })
local bodyM = Instance.new("Motor6D")
bodyM.Part0, bodyM.Part1, bodyM.Parent = root, upper, root

-- Kepala kubah + torso
local HY = 4.4
local head = mk(V(8.2, 8.7, 8.2), CFrame.new(0, HY * S, 0), C.BodyColor, { round = true })
weld(upper, head)
weld(upper, mk(V(6.6, 3.2, 6.6), CFrame.new(0, 0.7 * S, 0), C.BodyColor, { round = true }))

-- Kubus stud di permukaan kepala (spiral Fibonacci)
for i = 0, 43 do
	local y = 1 - (i + 0.5) / 22
	local r = math.sqrt(math.max(0, 1 - y * y))
	local th = i * 2.4
	local d = Vector3.new(math.cos(th) * r, y, math.sin(th) * r)
	local eyeZone = d.Z < -0.45 and math.abs(d.X) < 0.7 and math.abs(y - 0.05) < 0.75
	if y > -0.6 and not eyeZone then
		local pos = Vector3.new(d.X * 4.2, HY + d.Y * 4.45, d.Z * 4.2) * S
		local gold = i % 9 == 4
		local col = gold and C.GoldColor or (i % 4 == 0 and C.AccentColor or C.BodyColor)
		weld(upper, mk(V(1.1, 1.1, 1.1), CFrame.lookAt(pos, pos + d), col, { neon = gold }))
	end
end

-- Mata oval + pupil vertikal + bingkai ungu
local eyeY = HY + 0.2
local plate = mk(V(3.6, 4.3, 1.6), CFrame.new(0, eyeY * S, -3.95 * S), C.GoldColor, { round = true })
weld(upper, plate)
weld(upper, mk(V(0.5, 3.7, 0.4), CFrame.new(0, eyeY * S, -4.6 * S), Color3.fromRGB(70, 45, 0), { plain = true }))
for i = 0, 15 do
	local a = i / 16 * math.pi * 2
	local x, yy = math.cos(a) * 2.4, math.sin(a) * 2.9
	local z = -4.1 * math.sqrt(math.max(0.05, 1 - (x / 4.1) ^ 2 - ((yy + 0.2) / 4.35) ^ 2))
	local pos = Vector3.new(x, HY + 0.2 + yy, z - 0.25) * S
	local n = Vector3.new(x / 16.8, (yy + 0.2) / 18.9, z / 16.8).Unit
	local gold = i % 4 == 0
	weld(upper, mk(V(1, 1, 1), CFrame.lookAt(pos, pos + n), gold and C.GoldColor or C.AccentColor))
end

-- Kerah (ring kubus) di bawah kepala
for i = 0, 11 do
	local a = i / 12 * math.pi * 2
	local d = Vector3.new(math.sin(a), 0, math.cos(a))
	local pos = d * 3.3 * S + Vector3.new(0, 0.1 * S, 0)
	local gold = i % 3 == 0
	weld(upper, mk(V(1.3, 1.1, 1.3), CFrame.lookAt(pos, pos + d), gold and C.GoldColor or C.AccentColor, { neon = gold }))
end

-- Rantai segmen (dipakai untuk tentakel & antena), digerakkan Motor6D
local function chain(parent, baseCF, n, L, w0, shr, rest, cols, tip, glow, amp)
	local Ls = L * S
	local base = mk(Vector3.new(w0 * S, w0 * S, Ls), baseCF, cols[1])
	weld(parent, base)
	local ch = { motors = {}, rest = rest, L = Ls, base = base, amp = amp, busy = false }
	local function joint(a, b, c0, c1)
		local m = Instance.new("Motor6D")
		m.Part0, m.Part1, m.C0, m.C1, m.Parent = a, b, c0, c1, a
		return m
	end
	local prev = base
	for i = 1, n do
		local w = math.max(w0 - shr * i, 0.35) * S
		local s = mk(Vector3.new(w, w, Ls), baseCF, cols[i % 2 + 1])
		ch.motors[i] = joint(prev, s, CFrame.new(0, 0, -Ls / 2) * CFrame.Angles(rest[i], 0, 0), CFrame.new(0, 0, Ls / 2))
		prev = s
	end
	local ts = tip * S
	local tp = mk(Vector3.new(ts, ts, ts), baseCF, C.GoldColor, { neon = glow })
	joint(prev, tp, CFrame.new(0, 0, -Ls / 2), CFrame.new(0, 0, ts / 2))
	if glow then
		local l = Instance.new("PointLight")
		l.Color, l.Range, l.Brightness, l.Parent = C.GoldColor, 10, 2, tp
	end
	ch.tip = tp
	return ch
end

local tents, ants = {}, {}
for k = 0, 5 do -- 6 tentakel
	local a = math.rad(30 + 60 * k)
	local dir = Vector3.new(math.sin(a), 0, -math.cos(a))
	local pos = dir * 2 * S + Vector3.new(0, -0.2 * S, 0)
	tents[k + 1] = chain(root, CFrame.lookAt(pos, pos + dir) * CFrame.Angles(0.35, 0, 0), 4, 2.6 * TSC, 2 * TSC,
		0.32 * TSC, { -0.1, -0.4, -0.45, -0.45 }, { C.AccentColor, C.BodyColor }, 1 * TSC, false, 1)
end
for _, sx in ipairs({ -1, 1 }) do -- 2 antena
	local dir = Vector3.new(sx * 0.5, 1, -0.1).Unit
	local pos = Vector3.new(sx * 1.8 * S, 8.3 * S, 0) + dir * 0.9 * S
	ants[#ants + 1] = chain(upper, CFrame.lookAt(pos, pos + dir), 2, 1.8, 0.55, 0.1, { -0.1, -0.15 },
		{ C.AccentColor, C.AccentColor }, 1.5, false, 0.6)
end

-- Posisi awal di atas GuritaPlace
local top = place.CFrame:PointToWorldSpace(Vector3.new(0, place.Size.Y / 2, 0))
local home = Vector3.new(top.X, top.Y + 3.4 * S, top.Z)
model:PivotTo(CFrame.new(home))
model.Parent = workspace

-- ============ UTILITAS ============
local function tw(i, p, t, st)
	TweenService:Create(i, TweenInfo.new(t, st or Enum.EasingStyle.Linear), p):Play()
end
local function T(t) return t / C.AnimSpeed end

local function snd(parent, id, vol, pitch)
	if id == "" then return end
	local s = Instance.new("Sound")
	s.SoundId, s.Volume, s.PlaybackSpeed, s.RollOffMaxDistance, s.Parent = id, vol or 1, pitch or 1, 120, parent
	s:Play()
	Debris:AddItem(s, 4)
end

local function onPlace(pos) -- hanya area GuritaPlace
	local rel, h = place.CFrame:PointToObjectSpace(pos), place.Size / 2
	return math.abs(rel.X) <= h.X and math.abs(rel.Z) <= h.Z and rel.Y >= h.Y - 3 and rel.Y <= h.Y + 60
end

local function clampPos(p)
	local rel = place.CFrame:PointToObjectSpace(p)
	local mx, mz = math.max(place.Size.X / 2 - 3 * S, 0), math.max(place.Size.Z / 2 - 3 * S, 0)
	local w = place.CFrame:PointToWorldSpace(Vector3.new(math.clamp(rel.X, -mx, mx), rel.Y, math.clamp(rel.Z, -mz, mz)))
	return Vector3.new(w.X, home.Y, w.Z)
end

local function getInfo(plr)
	local ch = plr and plr.Character
	local h = ch and ch:FindFirstChildOfClass("Humanoid")
	local r = ch and ch:FindFirstChild("HumanoidRootPart")
	if h and r and h.Health > 0 then return h, r end
end

local function flat(a, b) return (Vector3.new(a.X, 0, a.Z) - Vector3.new(b.X, 0, b.Z)).Magnitude end

-- ============ EFEK VOID ============
local function voidFX(pos, size)
	local fx = Instance.new("Part")
	fx.Shape, fx.Material, fx.Color, fx.Transparency = Enum.PartType.Ball, Enum.Material.Neon, C.VoidColor, 0.2
	fx.Anchored, fx.CanCollide, fx.CanQuery, fx.CanTouch = true, false, false, false
	fx.Size, fx.CFrame, fx.Parent = Vector3.one, CFrame.new(pos), fxFolder
	tw(fx, { Size = Vector3.one * (size or 9), Transparency = 1 }, 0.5, Enum.EasingStyle.Quad)
	local em = Instance.new("ParticleEmitter")
	em.Color, em.Size, em.Lifetime = ColorSequence.new(C.VoidColor), NumberSequence.new(1.2, 0), NumberRange.new(0.5, 1)
	em.Speed, em.SpreadAngle, em.Rate, em.LightEmission = NumberRange.new(10, 22), Vector2.new(180, 180), 0, 1
	em.Parent = fx
	em:Emit(25)
	local l = Instance.new("PointLight")
	l.Color, l.Range, l.Brightness, l.Parent = C.VoidColor, 14, 4, fx
	Debris:AddItem(fx, 1.2)
end

local function slow(h)
	if h:GetAttribute("VoidSlowed") then return end
	h:SetAttribute("VoidSlowed", true)
	local old = h.WalkSpeed
	h.WalkSpeed = old * C.VoidSlowMult
	task.delay(C.VoidSlowTime, function()
		if h.Parent then h.WalkSpeed = old end
		h:SetAttribute("VoidSlowed", nil)
	end)
end

local function hit(h, r, dmg)
	h:TakeDamage(dmg)
	voidFX(r.Position, 9)
	snd(r, C.HitSound, 1, 0.7)
	slow(h)
end

-- ============ SERANGAN ============
local function pose(ch, add, yaw, t, st)
	for i, m in ipairs(ch.motors) do
		tw(m, { C0 = CFrame.new(0, 0, -ch.L / 2) * CFrame.Angles(ch.rest[i] + (add[i] or 0), i == 1 and yaw or 0, 0) }, t, st)
	end
end

local function pickTent(pos)
	local rp = root.Position
	local dir = Vector3.new(pos.X - rp.X, 0, pos.Z - rp.Z)
	dir = dir.Magnitude > 0.1 and dir.Unit or root.CFrame.LookVector
	local best, bd = tents[1], -2
	for _, t in ipairs(tents) do
		local l = t.base.CFrame.LookVector
		local dp = Vector3.new(l.X, 0, l.Z).Unit:Dot(dir)
		if dp > bd then best, bd = t, dp end
	end
	local lv = best.base.CFrame:VectorToObjectSpace(dir)
	return best, math.clamp(math.atan2(-lv.X, -lv.Z), -1.1, 1.1)
end

local function melee(plr)
	local h, r = getInfo(plr)
	if not h then return end
	local t, yaw = pickTent(r.Position)
	t.busy = true
	pose(t, { 0.8, 0.6, 0.5, 0.4 }, yaw, T(0.3), Enum.EasingStyle.Quad) -- angkat
	snd(root, C.SwingSound, 1, 0.8)
	task.wait(T(0.3))
	pose(t, { -0.2, -0.5, -0.5, -0.3 }, yaw, T(0.12), Enum.EasingStyle.Quad) -- hantam
	task.wait(T(0.12))
	voidFX(t.tip.Position, 6)
	h, r = getInfo(plr)
	if h and onPlace(r.Position) and flat(r.Position, root.Position) <= C.AttackRange * 1.2 then
		hit(h, r, C.MeleeDamage)
	end
	task.wait(T(0.25))
	pose(t, {}, 0, T(0.35))
	task.wait(T(0.35))
	t.busy = false
end

local function projectile(origin, dir)
	local p = Instance.new("Part")
	p.Shape, p.Material, p.Color = Enum.PartType.Ball, Enum.Material.Neon, C.VoidColor
	p.Size = Vector3.one * C.ProjectileSize * S
	p.Anchored, p.CanCollide, p.CanQuery, p.CanTouch = true, false, false, false
	p.CFrame, p.Parent = CFrame.new(origin), fxFolder
	local em = Instance.new("ParticleEmitter")
	em.Color, em.Size, em.Lifetime = ColorSequence.new(C.VoidColor), NumberSequence.new(1.5, 0), NumberRange.new(0.4, 0.8)
	em.Rate, em.Speed, em.LightEmission, em.Parent = 60, NumberRange.new(2, 5), 1, p
	local l = Instance.new("PointLight")
	l.Color, l.Range, l.Brightness, l.Parent = C.VoidColor, 12, 3, p
	snd(p, C.ShootSound, 1, 1.2)
	local dist, conn = 0, nil
	conn = RS.Heartbeat:Connect(function(dt)
		if not p.Parent then conn:Disconnect() return end
		local step = C.ProjectileSpeed * dt
		local np = p.Position + dir * step
		p.CFrame = CFrame.new(np)
		dist += step
		for _, pl in ipairs(Players:GetPlayers()) do
			local h, r = getInfo(pl)
			-- damage hanya jika pemain berada di GuritaPlace
			if h and onPlace(r.Position) and (r.Position - np).Magnitude <= C.ProjectileSize * S / 2 + 2.5 then
				hit(h, r, C.ShootDamage)
				conn:Disconnect()
				p:Destroy()
				return
			end
		end
		if dist >= C.ProjectileRange or np.Y <= top.Y + 0.3 then
			voidFX(np, 7)
			conn:Disconnect()
			p:Destroy()
		end
	end)
end

local function shoot(plr)
	local h, r = getInfo(plr)
	if not h or not onPlace(r.Position) then return end -- hanya tembak target di GuritaPlace
	local t, yaw = pickTent(r.Position)
	t.busy = true
	pose(t, { 0.7, 0.9, 0.8, 0.6 }, yaw, T(0.4), Enum.EasingStyle.Quad)
	task.wait(T(0.4))
	local orb = Instance.new("Part")
	orb.Shape, orb.Material, orb.Color = Enum.PartType.Ball, Enum.Material.Neon, C.VoidColor
	orb.Size = Vector3.one * 0.5
	orb.CanCollide, orb.CanQuery, orb.CanTouch, orb.Massless = false, false, false, true
	orb.CFrame, orb.Parent = t.tip.CFrame * CFrame.new(0, 0, -t.tip.Size.Z), fxFolder
	weld(t.tip, orb)
	local em = Instance.new("ParticleEmitter")
	em.Color, em.Size, em.Lifetime = ColorSequence.new(C.VoidColor), NumberSequence.new(1, 0), NumberRange.new(0.3, 0.6)
	em.Rate, em.Speed, em.LightEmission, em.Parent = 40, NumberRange.new(3, 8), 1, orb
	local l = Instance.new("PointLight")
	l.Color, l.Range, l.Brightness, l.Parent = C.VoidColor, 12, 4, orb
	snd(orb, C.ChargeSound, 1, 0.5)
	tw(orb, { Size = Vector3.one * C.ProjectileSize * S }, T(0.5))
	task.wait(T(0.5))
	h, r = getInfo(plr)
	if h and onPlace(r.Position) then
		local o = orb.Position
		local aim = r.Position + r.AssemblyLinearVelocity * ((r.Position - o).Magnitude / C.ProjectileSpeed) * 0.6
		orb:Destroy()
		pose(t, { -0.3, -0.3, -0.3, -0.3 }, yaw, T(0.12))
		projectile(o, (aim - o).Unit)
		task.wait(T(0.3))
	else
		orb:Destroy()
	end
	pose(t, {}, 0, T(0.35))
	task.wait(T(0.35))
	t.busy = false
end

-- ============ AI ============
local state, target, busy, acc = "Idle", nil, false, 0
local nextMelee, nextShoot = 0, 0

local function findTarget()
	local best, bd
	for _, p in ipairs(Players:GetPlayers()) do
		local h, r = getInfo(p)
		if h and onPlace(r.Position) then -- hanya pemain di atas GuritaPlace
			local d = flat(r.Position, root.Position)
			if d <= C.DetectRange and (not bd or d < bd) then best, bd = p, d end
		end
	end
	return best
end

local function launch(f, plr)
	busy = true
	task.spawn(function()
		local ok, e = pcall(f, plr)
		if not ok then warn("[Gurita]", e) end
		for _, t in ipairs(tents) do t.busy = false end
		busy = false
	end)
end

local conn
conn = RS.Heartbeat:Connect(function(dt)
	if not model.Parent then conn:Disconnect() return end
	acc += dt
	if acc >= 0.25 then acc = 0; target = findTarget() end
	local h, r
	if target then
		h, r = getInfo(target)
		if not (h and onPlace(r.Position)) then target = nil end -- keluar area = berhenti
	end
	local pos = root.Position
	local goal = target and Vector3.new(r.Position.X, home.Y, r.Position.Z) or home
	local to = goal - pos
	local dist = to.Magnitude
	local stop = target and C.AttackRange * 0.7 or 0.5
	local newPos = pos
	if dist > stop then newPos = pos + to.Unit * math.min(C.MoveSpeed * dt, dist - stop) end
	local rot = root.CFrame.Rotation
	local face = Vector3.new(to.X, 0, to.Z)
	if (target or dist > 1) and face.Magnitude > 0.05 then
		rot = rot:Lerp(CFrame.lookAt(Vector3.zero, face), math.min(1, dt * C.TurnSpeed))
	end
	root.CFrame = CFrame.new(clampPos(newPos)) * rot

	state = busy and "Attack" or (dist > stop + 0.1 and (target and "Chase" or "Return")) or "Idle"

	if target and not busy then
		local now = os.clock()
		local d = flat(r.Position, root.Position)
		if d <= C.AttackRange and now >= nextMelee then
			nextMelee = now + C.MeleeCooldown
			launch(melee, target)
		elseif d <= C.ShootRange and now >= nextShoot then
			nextShoot = now + C.ShootCooldown
			launch(shoot, target)
		end
	end
end)

-- ============ ANIMASI (idle, kejar, tentakel bergelombang) ============
task.spawn(function()
	local STEP, phase = 0.2, 0
	while model.Parent do
		local fast = (state == "Chase" or state == "Return") and 1.7 or 1
		phase += STEP * C.AnimSpeed * fast
		local function wave(ch, k)
			if ch.busy then return end
			for i, m in ipairs(ch.motors) do
				local ph = phase * 2 + k * 1.1 + i * 0.8
				local p = ch.rest[i] + math.sin(ph) * 0.2 * ch.amp * (fast > 1 and 1.4 or 1)
				local y = math.sin(ph * 0.7 + k) * 0.15 * ch.amp
				tw(m, { C0 = CFrame.new(0, 0, -ch.L / 2) * CFrame.Angles(p, y, 0) }, STEP)
			end
		end
		for k, ch in ipairs(tents) do wave(ch, k) end
		for k, ch in ipairs(ants) do wave(ch, k + 7) end
		local tilt = (fast > 1) and -0.12 or 0
		tw(bodyM, { C0 = CFrame.new(0, math.sin(phase * 1.2) * 0.45 * S, 0) * CFrame.Angles(tilt, 0, 0) }, STEP)
		task.wait(STEP)
	end
end)

print("[Gurita] Boss aktif di atas " .. C.PlaceName)