0% found this document useful (0 votes)
152 views2 pages

Roblox Slendytubby Monster Script

The document contains a Lua script for a game that manages the spawning and behavior of a monster named 'Slendytubby'. It includes configurations for the monster's attributes, a function to find the nearest player, and a chase loop that allows the monster to pursue and attack players within a specified range. The script also handles monster creation and ensures that a limited number of monsters are active at any given time.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
152 views2 pages

Roblox Slendytubby Monster Script

The document contains a Lua script for a game that manages the spawning and behavior of a monster named 'Slendytubby'. It includes configurations for the monster's attributes, a function to find the nearest player, and a chase loop that allows the monster to pursue and attack players within a specified range. The script also handles monster creation and ensures that a limited number of monsters are active at any given time.
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local ServerStorage = game:GetService("ServerStorage")


local Players = game:GetService("Players")
local PathfindingService = game:GetService("PathfindingService")

local Config = {
MonsterName = "Slendytubby",
ModelName = "SlendytubbyModel",
MaxActive = 2,
SpawnInterval = 25,
ChaseRadius = 120,
AttackRange = 3,
Damage = 25,
WalkSpeed = 16,
RunSpeed = 28
}

local RemoteFolder = ReplicatedStorage:FindFirstChild("SlendyRemote") or


[Link]("Folder")
[Link] = "SlendyRemote"
[Link] = ReplicatedStorage

local NotifyEvent = RemoteFolder:FindFirstChild("Notify") or


[Link]("RemoteEvent")
[Link] = "Notify"
[Link] = RemoteFolder

local function getNearestPlayer(pos)


local nearestPlayer = nil
local nearestDist = [Link]
for _, player in ipairs(Players:GetPlayers()) do
if [Link] and
[Link]:FindFirstChild("HumanoidRootPart") then
local dist = ([Link] -
pos).Magnitude
if dist < nearestDist then
nearestDist = dist
nearestPlayer = player
end
end
end
return nearestPlayer, nearestDist
end

local function createMonster()


local template = ServerStorage:FindFirstChild([Link])
if not template then return end
local monster = template:Clone()
[Link] = [Link]
[Link] = workspace
monster:SetPrimaryPartCFrame([Link]([Link](-100, 100), 10,
[Link](-100, 100)))
local humanoid = monster:FindFirstChildOfClass("Humanoid")
if humanoid then [Link] = [Link] end
return monster
end

local function attackPlayer(monster, player)


if not [Link] then return end
local humanoid = [Link]:FindFirstChildOfClass("Humanoid")
if humanoid and [Link] > 0 then
humanoid:TakeDamage([Link])
NotifyEvent:FireClient(player, "O " .. [Link] .. " te
atacou!")
end
end

local function chaseLoop(monster)


[Link](function()
local humanoid = monster:FindFirstChildOfClass("Humanoid")
local root = monster:FindFirstChild("HumanoidRootPart")
if not humanoid or not root then return end
while [Link] > 0 do
local target, dist = getNearestPlayer([Link])
if target and [Link] and dist < [Link] then
local tRoot =
[Link]:FindFirstChild("HumanoidRootPart")
if tRoot then
[Link] = [Link]
local path = PathfindingService:CreatePath()
path:ComputeAsync([Link], [Link])
for _, wp in ipairs(path:GetWaypoints()) do
if [Link] <= 0 then break end
humanoid:MoveTo([Link])
[Link]:Wait()
if ([Link] - [Link]).Magnitude
<= [Link] then
attackPlayer(monster, target)
end
end
end
else
[Link] = [Link]
[Link](1)
end
[Link](0.2)
end
monster:Destroy()
end)
end

[Link](function()
while true do
local count = 0
for _, obj in ipairs(workspace:GetChildren()) do
if [Link] == [Link] then
count += 1
end
end
if count < [Link] then
local newMonster = createMonster()
if newMonster then chaseLoop(newMonster) end
end
[Link]([Link])
end
end)

You might also like