Heres what I added before the line:
And here is the output:
Also, I wouldn’t know what specifically to send to you, so let me provide the entire open source module:
--[[Pokemon: Ultra Mystery Dungeon Main Dungeon Module]]--
--[[
>>Credits:
--@NolanC
--@SorrowScripts
--]]
--[Services]
local replicatedStorage = game:GetService("ReplicatedStorage")
local replicatedFirst = game:GetService("ReplicatedFirst")
local userInputService = game:GetService("UserInputService")
--[Directories]
local clientModulesFolder = replicatedStorage:WaitForChild("ClientModules")
local guisFolder = replicatedStorage:WaitForChild("Gui")
local assetsFolder = replicatedStorage:WaitForChild("Assets")
local chunksFolder = replicatedStorage:WaitForChild("Chunks")
local dungeonsFolder = replicatedStorage:WaitForChild("Dungeons")
--[Modules]
local ChunkService = require(clientModulesFolder:WaitForChild("ChunkService"))
local guiModule = require(guisFolder:WaitForChild("GuiModule"))
local utilities = require(clientModulesFolder:WaitForChild("Utilities"))
local playerData = require(clientModulesFolder:WaitForChild("PlayerData"))
local animations = require(assetsFolder:WaitForChild("Animations"))
local dungeonGui = require(guisFolder:WaitForChild("DungeonGui"))
--[Others]
local players = game:GetService("Players")
local player = players.LocalPlayer
local playerGui = player:WaitForChild("PlayerGui")
local runService = game:GetService("RunService")
local camera = workspace.CurrentCamera
--[Utilites]
local createObject = utilities.CreateObject
local tween = utilities.Tween
local playAnimation = utilities.PlayAnimation
local signal = utilities.Signal()
--[DungeonModule]
local DungeonModule = {
["Index"] = {
["Shady Forest"] = {
["Floors"] = 4,
["EnemyPokemon"] = {
--[["Nincada",
"Seedot",
"Wurmple",
"Caterpie",
"Plusle",
"Minun",]]
"Charmander",
"Treecko",
"Totodile"
},
["ItemsPossible"] = {
"Apple",
"Perfect Apple"
}
},
},
["InputsEnabled"] = false
}
--[Local Utilites]
local function GetDungeonLevel(dungeonID)
local dungeon
local success, err = pcall(function()
if dungeonID == "Shady Forest" then
local dungeonFolder = dungeonsFolder:WaitForChild("Shady Forest")
if not workspace:FindFirstChild("Level1") then
dungeon = dungeonFolder:WaitForChild("Level1"):Clone()
dungeon.Parent = workspace
dungeon.Name = "DungeonChunk"
elseif not workspace:FindFirstChild("Level2") then
dungeon = dungeonFolder:WaitForChild("Level2"):Clone()
dungeon.Parent = workspace
dungeon.Name = "DungeonChunk"
elseif not workspace:FindFirstChild("Level3") then
dungeon = dungeonFolder:WaitForChild("Level3"):Clone()
dungeon.Parent = workspace
dungeon.Name = "DungeonChunk"
elseif not workspace:FindFirstChild("Level4") then
dungeon = dungeonFolder:WaitForChild("Level4"):Clone()
dungeon.Parent = workspace
dungeon.Name = "DungeonChunk"
end
else
if workspace:FindFirstChild("DungeonChunk") then
pcall(function()
workspace:FindFirstChild("DungeonChunk"):Remove()
end)
end
local dungeonFolder = dungeonsFolder:WaitForChild(dungeonID)
dungeon = dungeonFolder:WaitForChild(math.random(1, #dungeonFolder:GetChildren())):Clone()
dungeon.Parent = workspace
dungeon.Name = "DungeonChunk"
end
end)
if not success then
warn("Request Dungeon Folder Failed:", err)
end
return dungeon
end
function pickUpItem(pokemon, amount, item)
dungeonGui.MessageLog((pokemon.." picked up (x"..amount..") "..item.. if amount == 1 then "." else "(s)."))
end
--[PathFinding]
local nodeSpacing = 7
--Required for A* pathfinding algorithm.
local openList = {}
local closedList = {}
local validDirections = {
Vector3.new(1, 0, 0),
Vector3.new(-1, 0, 0),
Vector3.new(1, 0, 1),
Vector3.new(-1, 0, -1),
Vector3.new(1, 0, -1),
Vector3.new(-1, 0, 1),
Vector3.new(0, 0, 1),
Vector3.new(0, 0, -1)
}
--Getting the dungeon pathfinding folder
if not workspace:FindFirstChild("DungeonPaths") then
createObject("Folder", {
Name = "DungeonPaths",
Parent = workspace
})
end
local dungeonPathsFolder = workspace:WaitForChild("DungeonPaths")
function createPart(position, parent)
local part = createObject("Part", {
Name = "Node",
BrickColor = BrickColor.Blue(),
Position = position,
Size = Vector3.new(1, 1, 1),
Anchored = true,
CanCollide = false,
Parent = parent,
createObject("IntValue", {
Name = "G",
Value = parent.G.Value + 1,
})
})
return part
end
function castRay(start, direction)
return workspace:FindPartOnRay(Ray.new(start, direction * nodeSpacing))
end
function tracePath(finalNode)
local current = finalNode
repeat
current.BrickColor = BrickColor.Yellow()
current = current.Parent
until current.Parent == workspace
end
function createGoalTile(goalTile)
print("yas")
print(goalTile.Parent)
local goalPart = goalTile:Clone()
goalPart.Parent = workspace
goalPart.Name = "Goal"
for i, j in pairs(goalPart:GetChildren()) do
j:Remove()
end
createObject("IntValue", {
Name = "G",
Parent = goalPart
})
return goalPart
end
function DungeonModule:CreatePath(start, goal)
local final = nil
table.insert(openList, start)
repeat --wait()
local low_F = math.huge
local best = nil
for l,node in ipairs(openList)do
local H = (node.Position - goal.Position).Magnitude * nodeSpacing
local G = node.G.Value
if G + H < low_F then
low_F = G + H
best = {node, l}
end
end
table.insert(closedList, best[1])
if best[1] ~= start then
best[1].BrickColor = BrickColor.Blue()
end
table.remove(openList, best[2])
for _,vector in ipairs(validDirections)do
local ray_Part, ray_Pos = castRay(best[1].Position, vector)
if not ray_Part then
local part = createPart(ray_Pos, best[1])
table.insert(openList, part)
end
end
final = best[1]
until #openList <= 0 or (best[1].Position - goal.Position).Magnitude <= nodeSpacing * 1.5
tracePath(final)
start:Remove()
goal:Remove()
return dungeonPathsFolder:GetChildren()
end
function DungeonModule:Floor(level, team)
local gui = createObject("ScreenGui", {
Parent = playerGui,
Name = "DungeonScreen",
IgnoreGuiInset = true
})
local background = createObject("Frame", {
Parent = gui,
BackgroundColor3 = Color3.new(0, 0, 0),
Size = UDim2.new(1, 0, 1, 0),
ZIndex = 1
})
local topText = createObject("TextLabel", {
Parent = background,
BackgroundTransparency = 1,
Size = UDim2.new(1, 0, 0.3, 0),
Position = UDim2.new(0, 0, 0.3, 0),
Font = Enum.Font.GothamBold,
TextScaled = true,
Name = "TopText",
TextColor3 = Color3.new(1, 1, 1),
TextTransparency = 1,
Text = self,
ZIndex = 2
})
local bottomText = createObject("TextLabel", {
Parent = background,
BackgroundTransparency = 1,
Size = UDim2.new(1, 0, 0.17, 0),
Position = UDim2.new(0, 0, 0.6, 0),
Font = Enum.Font.GothamBold,
TextScaled = true,
Name = "BottomText",
TextColor3 = Color3.new(1, 1, 1),
TextTransparency = 1,
Text = level.."F",
ZIndex = 2
})
tween(topText, {TextTransparency = 0}, 1)
task.wait(2)
tween(bottomText, {TextTransparency = 0}, 1)
task.wait(2)
tween(topText, {TextTransparency = 1}, 1)
tween(bottomText, {TextTransparency = 1}, 1)
local modelsFolder = replicatedStorage:WaitForChild("Models")
local itemModelsFolder = modelsFolder:WaitForChild("Items")
local dungeonLevel = GetDungeonLevel(self)
local tiles = dungeonLevel:WaitForChild("Tiles")
local playerPokemon = utilities.GetPokemon(playerData.PlayerPokemon)
local pokemonFolder = createObject("Folder", {
Parent = workspace,
Name = "Pokemon"
})
playerPokemon.Name = "Player"
playerPokemon.PrimaryPart.Anchored = true
playerPokemon.Parent = pokemonFolder
local playerTile = tiles:GetChildren()[math.random(1, #tiles:GetChildren())]
playerPokemon.PrimaryPart.CFrame = playerTile.CFrame
playerTile:SetAttribute("occupied", true)
playerTile:SetAttribute("occupiedBy", "pokemon")
playAnimation(playerPokemon, animations[playerData.PlayerPokemon.."Idle"])
for i = 1,1 --[[math.random(#DungeonModule.Index[self].EnemyPokemon,14)]] do
local randomPokemon = DungeonModule.Index[self].EnemyPokemon[math.random(1, #DungeonModule.Index[self].EnemyPokemon)]
local enemyPokemon = utilities.GetPokemon(randomPokemon)
enemyPokemon.Name = (randomPokemon)
enemyPokemon.PrimaryPart.Anchored = true
enemyPokemon.Parent = pokemonFolder
while true do
local enemyTile = tiles:GetChildren()[math.random(1, #tiles:GetChildren())]
if not enemyTile:GetAttribute("occupied") then
enemyPokemon.PrimaryPart.CFrame = enemyTile.CFrame
enemyTile:SetAttribute("occupied", true)
enemyTile:SetAttribute("occupiedBy", "pokemon")
break
else
enemyTile = tiles:GetChildren()[math.random(1, #tiles:GetChildren())]
end
break
end
playAnimation(enemyPokemon, animations[randomPokemon.."Idle"])
end
local function setItemAmount(item)
local itemsIndex = require(clientModulesFolder:WaitForChild("Items"))
return math.random(1, itemsIndex.Index[item])
end
for i = 1,10 do
local itemTile = tiles:GetChildren()[math.random(1,#tiles:GetChildren())]
local randomItem = DungeonModule.Index[self].ItemsPossible[math.random(1,#DungeonModule.Index[self].ItemsPossible)]
local itemModel = itemModelsFolder:WaitForChild(randomItem):Clone()
for i, itemData in pairs(itemModel:GetChildren()) do
if itemData:IsA("MeshPart") then
itemData.CanCollide = false
itemData.CanTouch = false
itemData.CanQuery = false
end
end
itemModel.Parent = itemTile
itemModel.PrimaryPart.CFrame = itemTile.CFrame
itemTile:SetAttribute("occupied", true)
itemTile:SetAttribute("occupiedBy", randomItem)
itemTile:SetAttribute("itemAmount", setItemAmount(randomItem))
end
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = CFrame.new(playerPokemon.PrimaryPart.Position + Vector3.new(0, 20, 10), playerPokemon.PrimaryPart.Position)
task.wait(1)
task.spawn(function()
tween(background, {BackgroundTransparency = 1}, 2)
task.wait(2)
pcall(function()
background:Remove()
topText:Remove()
bottomText:Remove()
end)
end)
local function inputValid(key, keys)
for _, v in pairs(keys) do
if key == v then
return true
end
end
return false
end
--[Input System]
local function startInputs()
local validKeys = {"W", "A", "S", "D"}
local connection = userInputService.InputBegan:Connect(function(input)
if DungeonModule.InputsEnabled then
local key = input.KeyCode.Name
if inputValid(key, validKeys) then
local distanceTable = {
W = Vector3.new(0, 0, -7),
A = Vector3.new(-7, 0, 0),
S = Vector3.new(0, 0, 7),
D = Vector3.new(7, 0, 0),
}
local rotationTable = {
W = 0,
A = 90,
S = 180,
D = -90,
}
if workspace:FindFirstChild("Start") then
workspace:WaitForChild("Start"):Remove()
workspace:WaitForChild("Goal"):Remove()
end
local goal
for i, tile in pairs(tiles:GetChildren()) do
local primaryPart = playerPokemon.PrimaryPart
print(primaryPart.Position)
print(tile.Position)
print()
print(distanceTable[key])
print(key)
print()
print(tile:GetAttribute("occupiedBy"))
if tile.Position == primaryPart.Position + distanceTable[key] and tile:GetAttribute("occupiedBy") ~= "pokemon" then
print(tile.Parent)
goal = createGoalTile(tile)
print(goal.Parent)
tween(primaryPart, {CFrame = tile.CFrame * CFrame.Angles(0, math.rad(rotationTable[key]), 0)}, 0.25, nil, nil, true, function()
for i, tileLookAt in pairs(tiles:GetChildren()) do
if tileLookAt.Position == primaryPart.Position + distanceTable[key] then
playerPokemon:PivotTo(CFrame.lookAt(primaryPart.Position, tileLookAt.CFrame.Position))
end
end
end)
primaryPart.CFrame = CFrame.lookAt(primaryPart.Position, tile.CFrame.Position)
primaryPart:GetPropertyChangedSignal("Position"):Connect(function()
camera.CFrame = CFrame.new(playerPokemon.PrimaryPart.Position + Vector3.new(0, 20, 10), playerPokemon.PrimaryPart.Position)
end)
if tile:GetAttribute("occupied") and tile:GetAttribute("occupiedBy") ~= "pokemon" then
playerData.AddItemToBag(tile:GetAttribute("occupiedBy"), tile:GetAttribute("itemAmount"))
pickUpItem(playerData.PlayerName, tile:GetAttribute("itemAmount"), tile:GetAttribute("occupiedBy"))
utilities.PlaySound(require(assetsFolder:WaitForChild("Audio")).PickUpItem)
tile:SetAttribute("itemAmount", nil)
tile:WaitForChild(tile:GetAttribute("occupiedBy")):Remove()
tile:SetAttribute("occupiedBy", "pokemon")
end
elseif tile.Position == primaryPart.Position + distanceTable[key] and tile:GetAttribute("occupied") and tile:GetAttribute("occupiedBy") == "pokemon" then
utilities.PlaySound(require(assetsFolder:WaitForChild("Audio")).Boing)
end
task.wait() --Buffer
for i, enemy in pairs(pokemonFolder:GetChildren()) do
if enemy.Name ~= "Player" then
local start, enemyPart
pcall(function()
enemyPart = enemy.PrimaryPart
start = enemyPart:Clone()
start.Parent = workspace
start.Name = "Start"
local startNode = Instance.new("IntValue", start)
startNode.Name = "G"
for i, data in pairs(start:GetChildren()) do
if not data:IsA("IntValue") then
data:Remove()
end
end
end)
local path = DungeonModule:CreatePath(start, goal)
local function Magnitude(p)
return math.sqrt(p.X^2 + p.Y^2 + p.Z^2)
end
local function GetNextNode()
local currentDistance = math.huge
local currentObject
for i,v in pairs(path) do
if not v:IsA("BasePart") then continue end
local Distance = Magnitude(enemyPart.Position - v.Position)
if Distance <= currentDistance then
currentDistance = Distance
currentObject = v
end
end
return currentObject
end
local nextNode = GetNextNode()
for i, tileNode in pairs(tiles:GetChildren()) do
if tileNode.Position == nextNode.Position and tileNode:GetAttribute("occupiedBy") ~= "pokemon" then
tween(enemyPart, {CFrame = tileNode.CFrame})
if tileNode:GetAttribute("occupied") and tileNode:GetAttribute("occupiedBy") ~= "pokemon" then
pickUpItem(enemy.Name, tileNode:GetAttribute("itemAmount"), tileNode:GetAttribute("occupiedBy"))
tileNode:SetAttribute("itemAmount", nil)
tileNode:WaitForChild(tileNode:GetAttribute("occupiedBy")):Remove()
tileNode:SetAttribute("occupiedBy", "pokemon")
end
end
end
end
end
if tile:GetAttribute("occupiedBy") == "pokemon" then
tile:SetAttribute("occupiedBy", "")
tile:SetAttribute("occupied", false)
end
end
task.wait(0.251) --damn so precise
for i, tile in pairs(tiles:GetChildren()) do
for i, pokemon in pairs(pokemonFolder:GetChildren()) do
if tile.Position == pokemon.PrimaryPart.Position then
tile:SetAttribute("occupiedBy", "pokemon")
tile:SetAttribute("occupied", true)
end
end
end
else
return
end
end
end)
return connection
end
dungeonGui:Enable(self, (level.."F"), team)
DungeonModule.InputsEnabled = true
local inputs = startInputs()
local finishedFloor = signal:wait()
inputs:Disconnect()
dungeonGui:Disable()
if utilities.ScreenUtilities.fadeObject.BackgroundTransparency ~= 0 then
utilities.ScreenUtilities.FadeScreenIn(2, Color3.new(0, 0, 0))
end
utilities.ScreenUtilities.RemoveScreen()
return finishedFloor
end
--[Global Dungeon Init Function]
function DungeonModule:DoDungeon()
task.spawn(function()
guiModule:Disable()
end)
if utilities.ScreenUtilities.fadeObject.BackgroundTransparency ~= 0 then
utilities.ScreenUtilities.FadeScreenIn(2, Color3.new(0, 0, 0))
end
local won = true
utilities.ScreenUtilities.RemoveScreen()
for i = 1, self.Floors do
local success = DungeonModule.Floor(self.Name, i, self.Team)
if not success then
won = false
break
end
end
if won then
print("Dungeon Won")
else
print("Dungeon Lost")
end
return won
end
--[[
bro you've done so much am sorry i havent been on much am grinding my 2nd region
in my pbb i swear when its done ill grind umd and i mean it dawg.
if i dont just Dm me every day about it i gotchu
Bro you don't even gotta worry about it man, I totally understand. Absolutely no pressure and no rush man
]]
return DungeonModule
(I am aware that roblox does not like pokemon, but this is not going to be released, atleast I don’t plan on releasing this ever. This is simply a passion project that serves to better my programming knowledge.)