Styracosaurus Premium v2 (ANTI LAG: tidur saat tidak ada pemain, animasi 30x/detik) -- Script (BUKAN LocalScript) di ServerScriptService. Aksi: mengaung, menggigit, menyeruduk. -- Muncul & beraksi hanya di Part bernama "StyracoPlace".
-- Styracosaurus Premium v2 (ANTI LAG: tidur saat tidak ada pemain, animasi 30x/detik)
-- Script (BUKAN LocalScript) di ServerScriptService. Aksi: mengaung, menggigit, menyeruduk.
-- Muncul & beraksi hanya di Part bernama "StyracoPlace".
local Players, RunService, Debris = game:GetService("Players"), game:GetService("RunService"), game:GetService("Debris")
-- ===================== PENGATURAN =====================
local PLACE_NAME = "StyracoPlace"
local SCALE, MAX_HEALTH, RESPAWN_TIME, INVINCIBLE = 1, 800, 15, true
local DETECT, LOSE, PATROL, CHASE_MARGIN, EDGE_MARGIN = 90, 140, 40, 25, 6
local WALK, RUN = 8, 20
local BITE_RANGE, BITE_DMG, BITE_CD, BITE_TIME = 12, 20, 1.5, 0.8
local CH_MIN, CH_MAX, CH_SPEED, CH_DMG, CH_CD, CH_TIME, CH_DIST = 16, 70, 42, 40, 6, 1.8, 80
local WINDUP, RECOVER, GORE = 1, 1.2, 0.9
local HIT_R, KNOCK, KNOCK_UP = 7, 55, 35
local ROAR_TIME, ROAR_CD, ROAR_SOUND_ID = 2, 20, 0 -- isi ID suara untuk mengaung
local ACTIVE_RANGE = 300 -- Styraco "tidur" kalau tidak ada pemain sejauh ini dari tepi part
local UPDATE_STEP = 1 / 30 -- animasi 30x per detik (hemat server & jaringan)
local GRAY = Color3.fromRGB(128, 133, 143)
local DARK = Color3.fromRGB(70, 74, 84)
local LIGHT = Color3.fromRGB(176, 181, 190)
local CREAM = Color3.fromRGB(236, 228, 205)
local BEAK = Color3.fromRGB(48, 50, 58)
local EYE = Color3.fromRGB(255, 196, 30)
local BLACK = Color3.fromRGB(15, 15, 15)
-- ======================================================
local GROUND, V = 8 * SCALE, Vector3.new
local SURF = {"TopSurface", "BottomSurface", "LeftSurface", "RightSurface", "FrontSurface", "BackSurface"}
local SIDES = {{"L", -1}, {"R", 1}}
-- {nama, sisi x, posisi z, kaki depan?, fase langkah}
local LEGS = {{"FL", -1, -4.5, true, 0}, {"FR", 1, -4.5, true, math.pi}, {"BL", -1, 4.5, false, math.pi}, {"BR", 1, 4.5, false, 0}}
local LIMITS = {bite = BITE_TIME, windup = WINDUP, gore = GORE, roar = ROAR_TIME}
local place = nil
for _ = 1, 30 do
local f = workspace:FindFirstChild(PLACE_NAME, true)
if f and f:IsA("BasePart") then
place = f
break
end
task.wait(0.5)
end
if not place then
warn("[Styraco] Part '" .. PLACE_NAME .. "' tidak ditemukan (harus berupa Part).")
return
end
local function sc(cf)
return CFrame.new(cf.Position * SCALE) * (cf - cf.Position)
end
local function smooth(a)
a = math.clamp(a, 0, 1)
return a * a * (3 - 2 * a)
end
local function playSound(parent, id)
if id == 0 then
return
end
local s = Instance.new("Sound")
s.SoundId, s.RollOffMaxDistance, s.Volume, s.Parent = "rbxassetid://" .. id, 300, 2, parent
s:Play()
Debris:AddItem(s, 6)
end
-- ============ MEMBANGUN STYRACOSAURUS ============
local function buildDino(cf0)
local model = Instance.new("Model")
model.Name = "Styracosaurus"
local root = Instance.new("Part")
root.Name, root.Size, root.Transparency, root.CanTouch, root.CFrame = "HumanoidRootPart", V(2, 2, 2), 1, false, cf0
root.CanQuery, root.CastShadow = false, false
root.Parent = model
model.PrimaryPart = root
local parts, rels, M, B = {Root = root}, {Root = CFrame.new()}, {}, {}
-- add(nama, ukuran, posisi, warna, parent, titik sendi)
local function add(n, size, cf, col, par, jt)
local rel = sc(cf)
local p = Instance.new("Part")
p.Name, p.Size, p.Color, p.Material = n, size * SCALE, col, Enum.Material.Plastic
p.CanCollide, p.Massless, p.CanTouch, p.CFrame = false, true, false, cf0 * rel
p.CanQuery, p.CastShadow = false, false
for _, s in ipairs(SURF) do
p[s] = Enum.SurfaceType.Studs
end
local jc = CFrame.new((jt or cf.Position) * SCALE)
local m = Instance.new("Motor6D")
m.Name, m.Part0, m.Part1 = n, parts[par], p
m.C0, m.C1 = rels[par]:Inverse() * jc, rel:Inverse() * jc
m.Parent, p.Parent = p, model
parts[n], rels[n], M[n], B[n] = p, rel, m, m.C0
end
-- Badan, perut krem, punggung & bercak gelap
add("Body", V(9, 7.5, 15), CFrame.new(0, 0, 0), GRAY, "Root", V(0, 0, 0))
add("Belly", V(9.4, 2, 12), CFrame.new(0, -2.9, 0), CREAM, "Body")
add("Back", V(7, 1.5, 13), CFrame.new(0, 4.4, 0), DARK, "Body")
add("Hump", V(8, 3, 6), CFrame.new(0, 3.8, -3.5), GRAY, "Body")
for i, z in ipairs({-5, 0, 5}) do
for _, sd in ipairs(SIDES) do
add("Pa" .. sd[1] .. i, V(0.6, 2.4, 3), CFrame.new(4.6 * sd[2], 1.4, z), DARK, "Body")
add("Pb" .. sd[1] .. i, V(2.4, 0.5, 2.4), CFrame.new(1.9 * sd[2], 5.1, z), DARK, "Back")
end
end
-- Leher, kepala, moncong, paruh, rahang, gigi
add("Neck", V(5.5, 5.5, 4.5), CFrame.new(0, 1.5, -8.5), GRAY, "Body", V(0, 0.5, -6.5))
add("Head", V(6, 5.5, 7), CFrame.new(0, 1, -12.2), GRAY, "Neck", V(0, 1, -10.5))
add("Snout", V(4.2, 3.6, 5), CFrame.new(0, 0, -16.9), LIGHT, "Head")
add("Beak", V(3, 2.2, 2), CFrame.new(0, -0.5, -20.2), BEAK, "Snout")
add("Jaw", V(3.8, 1.2, 6), CFrame.new(0, -2.2, -15.6), LIGHT, "Head", V(0, -1.7, -12.5))
add("TeethU", V(3.2, 0.8, 4.5), CFrame.new(0, -1.9, -16.8), CREAM, "Snout")
add("TeethL", V(2.6, 0.6, 5), CFrame.new(0, -1.4, -15.8), CREAM, "Jaw")
-- Tanduk hidung panjang (3 tingkat) {jarak, lebar, panjang}
local hr = CFrame.Angles(0.75, 0, 0)
local p0, hd = V(0, 2.2, -16.2), V(0, math.sin(0.75), -math.cos(0.75))
for i, d in ipairs({{1.4, 1.8, 2.8}, {3.8, 1.3, 2.4}, {6, 0.8, 2.4}}) do
add("Horn" .. i, V(d[2], d[2], d[3]), CFrame.new(p0 + hd * d[1]) * hr, CREAM, i == 1 and "Snout" or "Horn" .. (i - 1))
end
-- Mata & tanduk kecil di atas mata
for _, sd in ipairs(SIDES) do
local n, s = sd[1], sd[2]
add("Eye" .. n, V(1, 1.2, 1.2), CFrame.new(3.05 * s, 1.8, -12.8), EYE, "Head")
add("Pu" .. n, V(0.4, 0.6, 0.6), CFrame.new(3.6 * s, 1.8, -13), BLACK, "Eye" .. n)
add("Brow" .. n, V(0.9, 2.2, 0.9), CFrame.new(2.3 * s, 4.3, -12.8) * CFrame.Angles(-0.4, 0, 0), CREAM, "Head")
end
-- Frill (perisai leher) bertingkat + lingkaran tanduk
local FC = CFrame.new(0, 3.4, -8.8) * CFrame.Angles(0.3, 0, 0)
for i, l in ipairs({{13, 4.5, -2.75}, {10.5, 3, 1}, {7, 2.5, 3.75}}) do
add("Fr" .. i, V(l[1], l[2], 1.6), FC * CFrame.new(0, l[3], 0), DARK, "Head")
add("Fi" .. i, V(l[1] - 2, l[2] - 1, 0.8), FC * CFrame.new(0, l[3], -0.9), GRAY, "Fr" .. i)
end
-- duri frill {x, v, sudut, panjang}
for i, q in ipairs({{0, 5, 0, 6.5}, {2.6, 5, 0.25, 5.5}, {4.4, 2.5, 0.6, 5}, {5.9, -0.5, 1, 4.5}, {6.5, -2.8, 1.45, 4}}) do
for _, sd in ipairs(SIDES) do
local s = sd[2]
if q[1] > 0 or s == 1 then
local dir = V(s * math.sin(q[3]), math.cos(q[3]), 0)
local base = V(q[1] * s, q[2], 0)
local rot = CFrame.Angles(0, 0, -s * q[3])
local l1, l2 = q[4] * 0.58, q[4] * 0.5
local n = sd[1] .. i
add("SA" .. n, V(1.5, l1, 1.5), FC * CFrame.new(base + dir * (l1 / 2 - 0.4)) * rot, CREAM, "Fr1")
add("SB" .. n, V(0.8, l2, 0.8), FC * CFrame.new(base + dir * (l1 + l2 / 2 - 0.6)) * rot, CREAM, "SA" .. n)
end
end
end
-- Ekor
add("Tail1", V(5, 5, 7), CFrame.new(0, 0.5, 10.5), GRAY, "Body", V(0, 0.5, 7))
add("Tail2", V(3.6, 3.6, 7), CFrame.new(0, 0.2, 16.5), GRAY, "Tail1", V(0, 0.3, 13.5))
add("Tail3", V(2.2, 2.2, 6), CFrame.new(0, 0, 22), DARK, "Tail2", V(0, 0.1, 19.5))
-- Empat kaki tebal, kuku krem
for _, lg in ipairs(LEGS) do
local n, x, z = lg[1], 3.7 * lg[2], lg[3]
add("Th" .. n, V(3.8, 4.5, 3.8), CFrame.new(x, -3, z), GRAY, "Body", V(x, -1.2, z))
add("Sh" .. n, V(3.2, 3, 3.2), CFrame.new(x, -6.1, z), DARK, "Th" .. n, V(x, -4.8, z))
add("Ft" .. n, V(3.8, 1, 4.6), CFrame.new(x, -7.5, z - 0.4), BEAK, "Sh" .. n, V(x, -7, z))
for i = -1, 1 do
add("To" .. n .. (i + 2), V(1, 0.6, 1), CFrame.new(x + i * 1.2, -7.7, z - 3), CREAM, "Ft" .. n)
end
end
local hum = Instance.new("Humanoid")
hum.MaxHealth, hum.Health, hum.HipHeight, hum.WalkSpeed = MAX_HEALTH, MAX_HEALTH, GROUND - 1, WALK
hum.RequiresNeck, hum.BreakJointsOnDeath = false, false
hum.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
-- matikan state yang tidak dipakai (lebih ringan)
for _, n in ipairs({"Climbing", "Flying", "FallingDown", "GettingUp", "PlatformStanding", "Ragdoll", "Seated", "Swimming"}) do
hum:SetStateEnabled(Enum.HumanoidStateType[n], false)
end
if INVINCIBLE then
hum:SetStateEnabled(Enum.HumanoidStateType.Dead, false)
end
hum.Parent = model
model.Parent = workspace
pcall(function()
root:SetNetworkOwner(nil)
end)
return model, hum, root, M, B
end
-- ============ ANIMASI ============
local function startAnimator(root, M, B, A)
local t, phase, w, low, acc = 0, 0, 0, 0, 0
local CF = CFrame.Angles
return RunService.Heartbeat:Connect(function(dt)
if not root.Parent or A.sleep then
return
end
acc += dt
if acc < UPDATE_STEP - 0.003 then
return
end
dt, acc = math.min(acc, 0.1), 0
t += dt
if A.dead then
A.deadT += dt
M.Body.C0 = B.Body * CFrame.new(0, -3 * SCALE * smooth(A.deadT / 1.2), 0) * CF(0, 0, 1.4 * smooth(A.deadT / 1.2))
return
end
for k, lim in pairs(LIMITS) do
if A[k] then
A[k] += dt
if A[k] >= lim then
A[k] = nil
end
end
end
local v = root.AssemblyLinearVelocity
local speed = Vector3.new(v.X, 0, v.Z).Magnitude
w += ((speed > 1 and not A.bite and not A.windup and not A.roar and 1 or 0) - w) * math.min(1, dt * 8)
phase += dt * speed * 0.26
local amp = (0.28 + 0.3 * math.clamp(speed / CH_SPEED, 0, 1)) * w
low += (((A.windup or A.charging) and 1 or 0) - low) * math.min(1, dt * 6)
local neckAdd, headAdd, jawAdd, ra = -0.5 * low, -0.25 * low, -0.08 * w, 0
if A.bite then
local p = A.bite / BITE_TIME
if p < 0.35 then
local a = smooth(p / 0.35)
neckAdd, headAdd, jawAdd = neckAdd + 0.35 * a, headAdd + 0.2 * a, -0.9 * a
elseif p < 0.55 then
local a = (p - 0.35) / 0.2
neckAdd, headAdd = neckAdd + 0.35 - 0.8 * smooth(a), headAdd + 0.2 - 0.45 * smooth(a)
jawAdd = -0.9 * (1 - smooth((a - 0.7) / 0.3))
else
local a = smooth((p - 0.55) / 0.45)
neckAdd, headAdd, jawAdd = neckAdd - 0.45 * (1 - a), headAdd - 0.25 * (1 - a), 0
end
end
if A.gore then -- kepala dilempar ke atas
local a = math.sin(math.pi * A.gore / GORE)
neckAdd, headAdd = neckAdd + 1.1 * a, headAdd + 0.4 * a
end
if A.roar then -- mengaung: kepala naik, mulut terbuka & bergetar
ra = math.clamp(math.sin(math.pi * A.roar / ROAR_TIME) * 3, 0, 1)
neckAdd, headAdd = neckAdd + 0.5 * ra, headAdd + 0.35 * ra
jawAdd = (-0.8 + math.sin(t * 25) * 0.08) * ra
end
M.Body.C0 = B.Body * CFrame.new(math.sin(phase) * 0.03 * w, math.abs(math.sin(phase)) * 0.35 * SCALE * w, 0) * CF(-0.06 * low + 0.08 * ra, 0, 0)
M.Neck.C0 = B.Neck * CF(neckAdd + math.sin(t * 1.6) * 0.02, 0, 0)
M.Head.C0 = B.Head * CF(headAdd, math.sin(t * 0.5) * 0.2 * (1 - w), 0)
M.Jaw.C0 = B.Jaw * CF(jawAdd, 0, 0)
for i = 1, 3 do
M["Tail" .. i].C0 = B["Tail" .. i] * CF(0, math.sin(phase - i * 0.7) * 0.18 * w + math.sin(t * 0.9 - i * 0.7) * 0.07 * (1 - w), 0)
end
local scrape = A.windup and math.min(1, A.windup / 0.2) or 0
for _, lg in ipairs(LEGS) do
local n, sp = lg[1], scrape > 0 and lg[4]
local ph = sp and (t * 12 + lg[5]) or (phase + lg[5])
local k = sp and 0.5 * scrape or amp
local hip, knee = math.sin(ph) * k, -math.max(0, math.cos(ph)) * k * 1.4
M["Th" .. n].C0 = B["Th" .. n] * CF(hip, 0, 0)
M["Sh" .. n].C0 = B["Sh" .. n] * CF(knee, 0, 0)
M["Ft" .. n].C0 = B["Ft" .. n] * CF(-(hip + knee) * 0.8, 0, 0)
end
end)
end
-- ============ HELPER ============
local function inRoad(pos)
local lp = place.CFrame:PointToObjectSpace(pos)
return math.abs(lp.X) <= place.Size.X / 2 + CHASE_MARGIN and math.abs(lp.Z) <= place.Size.Z / 2 + CHASE_MARGIN
and lp.Y > -30 and lp.Y < 100
end
local function clampToRoad(pos)
local lp = place.CFrame:PointToObjectSpace(pos)
local hx, hz = math.max(0, place.Size.X / 2 - EDGE_MARGIN), math.max(0, place.Size.Z / 2 - EDGE_MARGIN)
return (place.CFrame * CFrame.new(math.clamp(lp.X, -hx, hx), place.Size.Y / 2 + GROUND, math.clamp(lp.Z, -hz, hz))).Position
end
-- apakah ada pemain di dekat part? (kalau tidak, Styraco tidur)
local function playersNear()
for _, plr in ipairs(Players:GetPlayers()) do
local hrp = plr.Character and plr.Character:FindFirstChild("HumanoidRootPart")
if hrp then
local lp = place.CFrame:PointToObjectSpace(hrp.Position)
local ex = math.max(math.abs(lp.X) - place.Size.X / 2, 0)
local ez = math.max(math.abs(lp.Z) - place.Size.Z / 2, 0)
if ex * ex + ez * ez <= ACTIVE_RANGE * ACTIVE_RANGE then
return true
end
end
end
return false
end
local function nearestPlayer(origin, range)
local best, bestDist, bestHum
for _, plr in ipairs(Players:GetPlayers()) do
local c = plr.Character
local h = c and c:FindFirstChildOfClass("Humanoid")
local hrp = c and c:FindFirstChild("HumanoidRootPart")
if h and hrp and h.Health > 0 and inRoad(hrp.Position) then
local d = (hrp.Position - origin).Magnitude
if d <= range and (bestDist == nil or d < bestDist) then
best, bestDist, bestHum = hrp, d, h
end
end
end
return best, bestDist, bestHum
end
local function flatDist(a, b)
return Vector3.new(a.X - b.X, 0, a.Z - b.Z).Magnitude
end
local function faceTarget(root, pos)
local p = root.Position
root.CFrame = CFrame.lookAt(p, Vector3.new(pos.X, p.Y, pos.Z))
end
-- ============ SIKLUS HIDUP ============
local function spawnAndRun()
local top = (place.CFrame * CFrame.new(0, place.Size.Y / 2 + GROUND + 1, 0)).Position
local model, hum, root, M, B = buildDino(CFrame.new(top))
local A = {deadT = 0}
local conn = startAnimator(root, M, B, A)
hum.Died:Connect(function()
root.Anchored = true
A.bite, A.windup, A.gore, A.roar, A.charging, A.dead = nil, nil, nil, nil, false, true
end)
local lastBite, lastCharge, lastRoar = 0, -100, -100
local patrolTarget, nextPatrol = nil, 0
-- ujung tanduk mengenai pemain?
local function hitPlayers(hitList)
local look = root.CFrame.LookVector
local tip = root.Position + look * (20 * SCALE)
local dir = Vector3.new(look.X, 0, look.Z).Unit
local any = false
for _, plr in ipairs(Players:GetPlayers()) do
local c = plr.Character
local h = c and c:FindFirstChildOfClass("Humanoid")
local hrp = c and c:FindFirstChild("HumanoidRootPart")
if h and hrp and h.Health > 0 and not hitList[plr] and flatDist(hrp.Position, tip) <= HIT_R * SCALE
and math.abs(hrp.Position.Y - tip.Y) <= 10 * SCALE then
hitList[plr], any = true, true
h:TakeDamage(CH_DMG)
hrp:ApplyImpulse((dir * KNOCK + V(0, KNOCK_UP, 0)) * hrp.AssemblyMass)
end
end
return any
end
local function doCharge(target)
lastCharge = os.clock()
hum.WalkSpeed = 0
hum:MoveTo(root.Position)
A.windup = 0 -- menggaruk tanah, arah terkunci ke pemain
while A.windup and hum.Health > 0 do
if target.Parent then
faceTarget(root, target.Position)
end
task.wait(0.05)
end
if hum.Health <= 0 then
return
end
local look = root.CFrame.LookVector
local goal = clampToRoad(root.Position + Vector3.new(look.X, 0, look.Z).Unit * CH_DIST)
hum.WalkSpeed, A.charging = CH_SPEED, true
local hitList, hit, startT = {}, false, os.clock()
while hum.Health > 0 and os.clock() - startT < CH_TIME do
hum:MoveTo(goal)
if hitPlayers(hitList) then
hit = true
break
end
if flatDist(root.Position, goal) < 3 then
break
end
task.wait(0.05)
end
A.charging, hum.WalkSpeed = false, 0
hum:MoveTo(root.Position)
if hit then
A.gore = 0
while A.gore and hum.Health > 0 do
task.wait(0.05)
end
else
task.wait(RECOVER)
end
end
while model.Parent and hum.Health > 0 do
-- tidak ada pemain di dekat: tidur (diam, tanpa fisika & animasi)
if not playersNear() then
if not A.sleep then
A.sleep, A.chasing = true, false
hum:MoveTo(root.Position)
root.Anchored = true
end
task.wait(1)
continue
end
if A.sleep then
A.sleep, root.Anchored = false, false
pcall(function()
root:SetNetworkOwner(nil)
end)
end
if INVINCIBLE then
hum.Health = hum.MaxHealth
end
local lp = place.CFrame:PointToObjectSpace(root.Position)
if lp.Y < -15 or math.abs(lp.X) > place.Size.X / 2 + 8 or math.abs(lp.Z) > place.Size.Z / 2 + 8 then
root.AssemblyLinearVelocity, root.CFrame = V(0, 0, 0), CFrame.new(top)
hum:MoveTo(top)
end
local target, _, tHum = nearestPlayer(root.Position, A.chasing and LOSE or DETECT)
if target then
local first = not A.chasing
A.chasing = true
local d = flatDist(target.Position, root.Position)
if first and os.clock() - lastRoar > ROAR_CD then -- MENGAUNG
lastRoar = os.clock()
hum.WalkSpeed = 0
hum:MoveTo(root.Position)
faceTarget(root, target.Position)
A.roar = 0
playSound(root, ROAR_SOUND_ID)
while A.roar and hum.Health > 0 do
task.wait(0.1)
end
elseif d <= BITE_RANGE then -- GIGIT
hum.WalkSpeed = 0
hum:MoveTo(root.Position)
if not A.bite then
faceTarget(root, target.Position)
if os.clock() - lastBite >= BITE_CD then
lastBite, A.bite = os.clock(), 0
task.delay(BITE_TIME * 0.55, function()
if hum.Health > 0 and tHum.Health > 0 and target.Parent and flatDist(target.Position, root.Position) <= BITE_RANGE + 5 then
tHum:TakeDamage(BITE_DMG)
end
end)
end
end
elseif d >= CH_MIN and d <= CH_MAX and os.clock() - lastCharge >= CH_CD and not A.bite then
doCharge(target) -- SERUDUK
elseif not A.bite then
hum.WalkSpeed = RUN
hum:MoveTo(clampToRoad(target.Position))
end
else
A.chasing = false
hum.WalkSpeed = WALK
if patrolTarget == nil or os.clock() >= nextPatrol then
local rx = (math.random() - 0.5) * math.min(place.Size.X * 0.6, PATROL * 2)
local rz = (math.random() - 0.5) * math.min(place.Size.Z * 0.6, PATROL * 2)
patrolTarget, nextPatrol = (place.CFrame * CFrame.new(rx, 0, rz)).Position, os.clock() + math.random(4, 8)
end
hum:MoveTo(patrolTarget)
end
task.wait(0.2)
end
task.wait(4)
conn:Disconnect()
model:Destroy()
end
task.spawn(function()
repeat
spawnAndRun()
if RESPAWN_TIME > 0 then
task.wait(RESPAWN_TIME)
end
until RESPAWN_TIME <= 0
end)