How to connect and share modules between scripts

it didn’t work :frowning:

My bomb module :

-- spook 6/04/24
local Seed = Random.new()
local bombclass = {}
local Replicated = game:GetService("ReplicatedStorage")
local SV = game:GetService("ServerStorage")
local bombfolder = SV:WaitForChild("BombModels")
local terrain = workspace.Terrain
local debrisService = game:GetService("Debris")
local libraries = Replicated:WaitForChild("Libraries")
local Zonemod = libraries:WaitForChild("Zone")
local requireZone = require(Zonemod)
local AssetsFolder = script:WaitForChild("Assets", 999)
local effectshandlerpart = AssetsFolder:WaitForChild("effectsHandler")
local TemporalFolder = workspace:WaitForChild("Temporal")
local collectionService = game:GetService("CollectionService")

local runSd = Replicated:WaitForChild("RunServiceTween")
local tPlus = Replicated:WaitForChild("TweenServicePlus")
local easyclientT = Replicated:WaitForChild("EasyClientTween")
local ReplicatedTweening = Replicated:WaitForChild("ReplicatedTweening")

local requireEasyTween = require(easyclientT)
local requireRunServ = require(runSd)
local requiretPlus = require(tPlus)
local requireTV2 = require(ReplicatedTweening)

local BombVisualRemote = Replicated:WaitForChild("BombVisual")


-- // ASSETS ZONE // --

local tickhighlight = AssetsFolder:WaitForChild("tickhighlight")
local tickeffectAttachment = effectshandlerpart:WaitForChild("tickeffect")
local explosionEffectAttachment = effectshandlerpart:WaitForChild("explosionEffect")
local explosionEffect2Attachment = effectshandlerpart:WaitForChild("explosioneffect2")
local ExpoEffect1Yellow = AssetsFolder:WaitForChild("expo1")
local ExpoEffect2Red = AssetsFolder:WaitForChild("expo2")


--///////////////////

local BombHandler = nil
local VerifyBombModel = nil

local BombClearEventHandler = nil

local settingsModule = {
	bombName = "classicbomb",
	TickTimeToExplode = 1.1,

	HitboxSize = Vector3.new(17, 17, 17.5),
	HitboxColor = Color3.fromRGB(173, 0, 0),
	HitboxTransparency = 0.5,
	HitboxOffset = Vector3.new(0, 0.1, 0),
	DebugHitbox = false,

	TimeToStartTicking = 5,
	DecreaseTickTimeCount = 0.2,
	TickSoundName = "",
	showHitbox = true,
	ExplosionSoundName = "",
	Damage = 10,
	DestroyWeldsChance = 50, -- porcentage 0.5
	DestroyPartsChance = 61, --porcentage 0.6
}

-- // Tween Information // --

local TweenInfos = {
	Expo1YellowSize = {TweenInfo.new(
		0.45,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut
		)},
	Expo1YellowTransparency = {TweenInfo.new(
		1,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut
		)},
	Expo2RedSize = {TweenInfo.new(
		0.55,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut
		)},
	Expo2RedTransparency = {TweenInfo.new(
		0.4,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut
		)},
}

local goals = {
	Shrink = {
		Size = Vector3.new(0.000, 0.000, 0.000),
	},
	Disappear = {
		Transparency = 1
	}
}



--//////

function bombclass:RandomChance(tabla)
	local Sum = 0

	for _, Table in ipairs(tabla) do
		Sum += Table.Chance
	end

	local RNG = Random.new():NextInteger(1, Sum)

	local Weight = 0

	for _, Table in ipairs(tabla) do
		Weight += Table.Chance
		if Weight >= RNG then
			return Table.Rarity
		end
	end
end


function bombclass:SearchIn(folder : Folder , name : string, selectRandom : boolean)
	if folder and folder:IsA("Folder") then
		if not selectRandom then
			for _, objects in pairs(folder:GetChildren()) do
				if objects then
					if folder:FindFirstChild(settingsModule.TickSoundName) then
						local getItem = folder:WaitForChild(settingsModule.TickSoundName)
						if getItem then
							return getItem
						end
					else
						return nil
					end
				end

			end
		else
			local getChildren = folder:GetChildren()
			local choosenitem = getChildren[Seed:NextInteger(1, #getChildren)]
			if choosenitem then
				return choosenitem
			else
				return nil
			end
		end
	end
end

function bombclass:EmitFromAttachment(attachment, amount)
	if attachment:IsA("Attachment") then
		for _, particles in pairs(attachment:GetChildren()) do
			if particles:IsA("ParticleEmitter") then
				particles:Emit(amount)
			end
		end
	end
end

function bombclass:DisableParticlesFromAttachment(attachment)
	if attachment:IsA("Attachment") then
		for _, particles in pairs(attachment:GetDescendants()) do
			if particles:IsA("ParticleEmitter") then
				particles.Enabled = false
			end
		end
	end
end

function bombclass:EnableFromAttachment(attachment : Attachment, duration : number)
	task.spawn(function()
		if attachment:IsA("Attachment") then
			for _, particles in pairs(attachment:GetChildren()) do
				if particles:IsA("ParticleEmitter") then
					if duration then
						particles.Enabled = true
						task.delay(duration, function()
							particles.Enabled = false
						end)
					else
						particles.Enabled = true
					end
				end
			end
		end
	end)
end


function bombclass:DestroyBomb()
	if self.VerifyBombModel then
		self.VerifyBombModel:Destroy()
		-- make visual effects when destroying bomb, etc., here
	end
end


return function(bomb, selectedTag : string)
	task.spawn(function()
		local self = {}

		setmetatable(self, bombclass)


		self.bombModelVerify = bomb
		VerifyBombModel = self.bombModelVerify

		-- // Search folders
		self.specifiedBombFolder = nil
		self.SoundsFolderBomb = nil
		self.tickSoundsFolder = nil
		self.explosionsSoundFolder = nil
		-- /////

		self.settings = settingsModule


		self.CurrentTickSoundAttachment = nil
		self.CurrentTickSound = nil

		self.CurrentExplosionSoundAttachment = nil
		self.CurrentExplosionSound = nil
		self.Chances_1 = nil

		self.bombmeshorpart = nil



		if bomb:IsA("Model") then
			for _, bombparts in pairs(bomb:GetDescendants()) do
				if bombparts:FindFirstChild("IsBombPart") then
					local isbombpart = bombparts:WaitForChild("IsBombPart")
					if isbombpart:IsA("RayValue") then
						self.bombmeshorpart = bombparts
					end
				end
			end
		else
			self.bombmeshorpart = bomb
		end

		-- Put Assets .self here --
		task.wait()

		self.tickhighlight = nil
		self.tickattacheffect = nil
		self.bombExpEffectAttach = nil
		self.bombExpEffect2Attach = nil
		self.expoEffect1Yellow = nil
		self.expoEffect2Red = nil

		if self.bombmeshorpart then

			print(self.bombmeshorpart.Name)

			self.tickhighlight = tickhighlight:Clone()
			self.tickhighlight.Enabled = false

			self.tickattacheffect = tickeffectAttachment:Clone()

			self.tickhighlight.Parent = self.bombmeshorpart
			self.tickattacheffect.Parent = self.bombmeshorpart
			self.tickattacheffect.WorldCFrame = self.bombmeshorpart.CFrame
			bombclass:DisableParticlesFromAttachment(self.tickattacheffect)

			self.bombExpEffectAttach = explosionEffectAttachment:Clone()
			self.bombExpEffectAttach.Parent = self.bombmeshorpart
			self.bombExpEffectAttach.WorldCFrame = self.bombmeshorpart.CFrame		
			bombclass:DisableParticlesFromAttachment(self.bombExpEffectAttach)

			self.bombExpEffect2Attach = explosionEffect2Attachment:Clone()
			self.bombExpEffect2Attach.Parent = self.bombmeshorpart
			self.bombExpEffect2Attach.WorldCFrame = self.bombmeshorpart.CFrame		
			bombclass:DisableParticlesFromAttachment(self.bombExpEffect2Attach)

		else
			warn(" no set")
		end

		--////

		self.CurrentTime = self.settings["TickTimeToExplode"]


		if bombfolder:FindFirstChild(selectedTag) then
			self.specifiedBombFolder = bombfolder:WaitForChild(selectedTag)
			self.SoundsFolderBomb = self.specifiedBombFolder:WaitForChild("Sounds")
			self.tickSoundsFolder = self.SoundsFolderBomb:WaitForChild("ticks")
			self.explosionsSoundFolder = self.SoundsFolderBomb:WaitForChild("Explosions")
		end


		warn(settingsModule or table.unpack(settingsModule))

		task.wait()

		task.wait(settingsModule["TimeToStartTicking"])

		
		local BombHandler = coroutine.create(function()
			for count = self.settings["DecreaseTickTimeCount"] , 10 do
				if VerifyBombModel then
					if self.bombmeshorpart ~= nil and bomb ~= nil then
						print(self.bombmeshorpart:GetFullName())
						self.CurrentTime -= .1

						if bomb:IsA("BasePart") or bomb:IsA("MeshPart") or bomb:IsA("Part") then
							if self.tickhighlight then
								self.tickhighlight.Enabled = false
							end

							bomb.Color = Color3.fromRGB(255, 255, 255)

							task.wait(self.CurrentTime)

							if self.tickhighlight then
								self.tickhighlight.Enabled = true
							end

							if self.tickattacheffect then
								task.spawn(function()
									bombclass:EmitFromAttachment(self.tickattacheffect, Seed:NextInteger(1, 10))
								end)
							end

							bomb.Color = Color3.fromRGB(255, 0, 0)
						else


							if self.tickhighlight then
								self.tickhighlight.Enabled = false
							end


							task.wait(self.CurrentTime)

							if self.tickhighlight then
								self.tickhighlight.Enabled = true
							end

							if self.tickattacheffect then
								task.spawn(function()
									bombclass:EmitFromAttachment(self.tickattacheffect, Seed:NextInteger(1, 10))
								end)
							end


						end


						if self.specifiedBombFolder then
							if (settingsModule["TickSoundName"] == "") or (settingsModule["TickSoundName"] == nil) then
								local searchForSound = bombclass:SearchIn(self.tickSoundsFolder, nil, true)
								if searchForSound then
									self.CurrentTickSoundAttachment = Instance.new("Attachment")
									self.CurrentTickSoundAttachment.Parent = terrain
									if bomb:IsA("Part") or bomb:IsA("BasePart") or bomb:IsA("MeshPart") then
										self.CurrentTickSoundAttachment.CFrame = bomb.CFrame 
									else
										self.CurrentTickSoundAttachment.CFrame = bomb:GetPivot()
									end

									self.CurrentTickSound = searchForSound:Clone()
									self.CurrentTickSound.Parent = self.CurrentTickSoundAttachment
									self.CurrentTickSound:Play()
									debrisService:AddItem(self.CurrentTickSoundAttachment, self.CurrentTickSound.TimeLength)
								end
							else
								local searchForSound = bombclass:SearchIn(self.tickSoundsFolder, settingsModule["TickSoundName"], false)
								if searchForSound then
									self.CurrentTickSoundAttachment = Instance.new("Attachment")
									self.CurrentTickSoundAttachment.Parent = terrain
									if bomb:IsA("Part") or bomb:IsA("BasePart") or bomb:IsA("MeshPart") then
										self.CurrentTickSoundAttachment.CFrame = bomb.CFrame 
									else
										self.CurrentTickSoundAttachment.CFrame = bomb:GetPivot()
									end
									self.CurrentTickSound = searchForSound:Clone()
									self.CurrentTickSound.Parent = self.CurrentTickSoundAttachment
									self.CurrentTickSound:Play()
									debrisService:AddItem(self.CurrentTickSoundAttachment, self.CurrentTickSound.TimeLength)
								end
							end
						end

						task.wait(self.CurrentTime)
					end
				end
			end


			if self.tickattacheffect then
				self.tickattacheffect.Parent =	self.bombmeshorpart
				if self.bombmeshorpart then
					self.tickattacheffect.WorldCFrame = self.bombmeshorpart.CFrame
					debrisService:AddItem(self.tickattacheffect, 1.5)
				end
			end
			if self.bombExpEffectAttach then
				self.bombExpEffectAttach.Parent = terrain
				self.bombExpEffectAttach.WorldCFrame = self.bombmeshorpart.CFrame
				if self.bombmeshorpart then
					self.bombExpEffectAttach.WorldCFrame = self.bombmeshorpart.CFrame
					debrisService:AddItem(self.bombExpEffectAttach, 1.5)
				end
			end

			if self.bombExpEffect2Attach then
				self.bombExpEffect2Attach.Parent = terrain
				self.bombExpEffect2Attach.WorldCFrame = self.bombmeshorpart.CFrame
				if self.bombmeshorpart then
					self.bombExpEffect2Attach.WorldCFrame = self.bombmeshorpart.CFrame
					debrisService:AddItem(self.bombExpEffect2Attach, 1.5)
				end
			end

			if self.tickhighlight then
				self.tickhighlight:Destroy()
			end

			if self.bombExpEffect2Attach then
				bombclass:EmitFromAttachment(self.bombExpEffect2Attach, Seed:NextInteger(5 , 11))
			end
			if self.bombExpEffectAttach then
				bombclass:EnableFromAttachment(self.bombExpEffectAttach, 0.4)
			end

			self.expoEffect1Yellow = ExpoEffect1Yellow:Clone()
			self.expoEffect2Red = ExpoEffect2Red:Clone()

			if self.expoEffect1Yellow then
				self.expoEffect1Yellow.Parent = TemporalFolder
				self.expoEffect1Yellow.CFrame = self.bombmeshorpart.CFrame + Vector3.new(0,0.4,0)


			end
			if self.expoEffect2Red then
				self.expoEffect2Red.Parent = TemporalFolder
				self.expoEffect2Red.CFrame = self.bombmeshorpart.CFrame + Vector3.new(0,0.4,0)

				self.expoEffect2Red.Size = self.expoEffect1Yellow.Size + Vector3.new(0.55, 0.55, 0.55)

			end	

			task.wait(.1)

			--local ExpoEffect1YellowShrink = requireTV2:GetTweenObject(self.expoEffect1Yellow, TweenInfo.new(0.45, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Size = Vector3.new(0,0,0)})
			local ExpoEffect1YellowTransparency = requireTV2:GetTweenObject(self.expoEffect1Yellow, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Transparency = 1})

			--local ExpoEffect2RedShrink = requireTV2:GetTweenObject(self.expoEffect2Red, TweenInfo.new(0.55, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Size = Vector3.new(0,0,0)})
			local ExpoEffect2RedTransparency = requireTV2:GetTweenObject(self.expoEffect2Red, TweenInfo.new(0.4, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Transparency = 1})

			local ExpoEffect1YellowShrink_ = requiretPlus.Construct(
				self.expoEffect1Yellow,
				self.expoEffect1Yellow,
				TweenInfo.new(
					0.45,
					Enum.EasingStyle.Sine,
					Enum.EasingDirection.InOut
				),
				{
					Size = Vector3.new(0,0,0)
				}


			)



			local ExpoEffect2RedShrink_ = requiretPlus.Construct(
				self.expoEffect2Red,
				self.expoEffect2Red,
				TweenInfo.new(
					0.55,
					Enum.EasingStyle.Sine,
					Enum.EasingDirection.InOut
				),
				{
					Size = Vector3.new(0,0,0)
				}


			)

			ExpoEffect1YellowShrink_:Play()
			ExpoEffect2RedShrink_:Play()

			--ExpoEffect2RedShrink:Play()
			ExpoEffect2RedTransparency:Play()

			--ExpoEffect1YellowShrink:Play()
			ExpoEffect1YellowTransparency:Play()

			debrisService:AddItem(self.expoEffect2Red, 1.5)
			debrisService:AddItem(self.expoEffect1Yellow, 1.6)

			if (settingsModule["ExplosionSoundName"] == "") or (settingsModule["ExplosionSoundName"] == nil) then
				local searchForSound = bombclass:SearchIn(self.explosionsSoundFolder, nil, true)
				if searchForSound then
					self.CurrentExplosionSoundAttachment = Instance.new("Attachment")
					self.CurrentExplosionSoundAttachment.Parent = terrain
					if bomb:IsA("Part") or bomb:IsA("BasePart") or bomb:IsA("MeshPart") then
						self.CurrentExplosionSoundAttachment.CFrame = bomb.CFrame 
					else
						self.CurrentExplosionSoundAttachment.CFrame = bomb:GetPivot()
					end

					self.CurrentExplosionSound = searchForSound:Clone()
					self.CurrentExplosionSound.Parent = self.CurrentExplosionSoundAttachment
					self.CurrentExplosionSound:Play()
					debrisService:AddItem(self.CurrentExplosionSound, self.CurrentExplosionSound.TimeLength)
					debrisService:AddItem(self.CurrentExplosionSoundAttachment, self.CurrentExplosionSound.TimeLength + 0.1)
				end
			else
				local searchForSound = bombclass:SearchIn(self.explosionsSoundFolder, settingsModule["ExplosionSoundName"], false)
				if searchForSound then
					self.CurrentExplosionSoundAttachment = Instance.new("Attachment")
					self.CurrentExplosionSoundAttachment.Parent = terrain
					if bomb:IsA("Part") or bomb:IsA("BasePart") or bomb:IsA("MeshPart") then
						self.CurrentExplosionSoundAttachment.CFrame = bomb.CFrame 
					else
						self.CurrentExplosionSoundAttachment.CFrame = bomb:GetPivot()
					end
					self.CurrentExplosionSound = searchForSound:Clone()
					self.CurrentExplosionSound.Parent = self.CurrentExplosionSoundAttachment
					self.CurrentExplosionSound:Play()
					debrisService:AddItem(self.CurrentExplosionSound, self.CurrentExplosionSound.TimeLength)
					debrisService:AddItem(self.CurrentExplosionSoundAttachment, self.CurrentExplosionSound.TimeLength + 0.1)
				end
			end

			local SphereHitbox = Instance.new("Part")
			SphereHitbox.Shape = Enum.PartType.Ball
			SphereHitbox.Parent = TemporalFolder
			SphereHitbox.Size = self.settings["HitboxSize"]
			SphereHitbox.Color = self.settings["HitboxColor"]
			SphereHitbox.CanCollide = false

			if self.settings["DebugHitbox"] == true then
				SphereHitbox.Transparency = self.settings["HitboxTransparency"] or 0.5
			else
				SphereHitbox.Transparency = 1
			end

			SphereHitbox.Anchored = true
			SphereHitbox.CFrame = self.bombmeshorpart.CFrame + self.settings["HitboxOffset"]

			local ZoneContainer = requireZone.new(SphereHitbox)

			local getthem = ZoneContainer:getParts()

			self.Chances_1 = {
				{Rarity = "DestroyWeld",     Chance = self.settings["DestroyWeldsChance"]};
				{Rarity = "DestroyPart",    Chance = self.settings["DestroyPartsChance"]};
			}

			ZoneContainer.playerEntered:Connect(function(player)
				if player then
					if player.Character then
						local character = player.Character
						if character then
							if character:FindFirstChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid") then
								local humanoid = character:WaitForChild("Humanoid") or character("Humanoid")
								if humanoid then
									if character:FindFirstChild("HealthV") then
										local healthValue = character:WaitForChild("HealthV")
										if healthValue:IsA("NumberValue") then
											healthValue.Value -= self.settings["Damage"]
										end
									end
								end
							end
						end
					end
				end
			end)

			if getthem then
				for _, part in pairs(getthem) do
					local tags = collectionService:GetTags(part)
					if not (part == SphereHitbox) then
						if not (part.Name == self.expoEffect1Yellow.Name) or (part.Name == self.expoEffect2Red.Name) then
							print(getthem)
							--if part.Name == "HumanoidRootPart" then
							--local parent = part.Parent
							--if parent:FindFirstChild("Humanoid") or parent:FindFirstChildWhichIsA("Humanoid") then
							--local humanoid = parent:WaitForChild("Humanoid") or parent:FindFirstChildWhichIsA("Humanoid")
							--if humanoid then
							--	if parent:FindFirstChild("HealthV") then
							--	local healthValue = parent:WaitForChild("HealthV")
							--if healthValue:IsA("NumberValue") then
							--	healthValue.Value -= self.settings["Damage"]
							--end
							--end
							--end
							--	end
							--end
							for _, tag in pairs(tags) do
								if tag then
									if tag == "candestroy" then
										if part:IsA("BasePart") or part:IsA("Part") then
											local IfRarity = bombclass:RandomChance(self.Chances_1)
											if IfRarity == "DestroyPart" then
												part:Destroy()
											elseif IfRarity == "DestroyWeld" then
												for _, welds in pairs(part:GetChildren()) do
													if welds then
														if welds:IsA("Weld") or welds:IsA("Motor6D") or welds:IsA("WeldConstraint") then
															welds:Destroy()
														end
													end
												end
											else
												warn("???!!!?!?!?! "..IfRarity)
											end
										end 
									end
								end
							end
						end
					end
				end
			end
			debrisService:AddItem(SphereHitbox, 0.3)	


			--BombVisualRemote:Fire( self.expoEffect1Yellow ,"tweenBombEffect1Yellow")
			--BombVisualRemote:Fire( self.expoEffect2Red ,"tweenBombEffect2Red")


			--local ExpoEffect1YellowShrink =
			--	requireEasyTween.new(
			--	self.expoEffect1Yellow, self.expoEffect1Yellow, TweenInfo.new(
			--	2, -- 0.45
			--	Enum.EasingStyle.Sine,
			--	Enum.EasingDirection.InOut
			--	)   ,goals["Shrink"]
			--)
			--local ExpoEffect1YellowDisappear = 
			--requireRunServ.Create(
			--	self.expoEffect1Yellow, self.expoEffect1Yellow,TweenInfo.new(
			--		2, -- 1
			--		Enum.EasingStyle.Sine,
			--		Enum.EasingDirection.InOut
			--	) , {Transparency = 1}
			--)
			--local ExpoEffect1RedShrink =
			--	requireRunServ.Create(
			--	self.expoEffect2Red, self.expoEffect2Red,TweenInfo.new(
			--		2, -- 0.55
			--		Enum.EasingStyle.Sine,
			--		Enum.EasingDirection.InOut
			--	) , goals["Shrink"]
			--)
			--local ExpoEffect1RedDisappear = 
			--requireRunServ.Create(
			--	self.expoEffect2Red, self.expoEffect2Red,TweenInfo.new(
			--	2, -- 0.4
			--	Enum.EasingStyle.Sine,
			--	Enum.EasingDirection.InOut
			--	) , {Transparency = 1}
			--	)


			--	tweenObject:TweenAllClients(self.expoEffect2Red, {
			--	TweenInfo.new(0.55, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)}, {Size = Vector3.new(0.000, 0.000, 0.000)}
			--)
			--	tweenObject:TweenAllClients(self.expoEffect2Red, {
			--	TweenInfo.new(0.4, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)}, {Transparency = 1}
			--)

			--ExpoEffect1YellowShrink:Play()
			--ExpoEffect1YellowDisappear:Play()

			--ExpoEffect1RedShrink:Play()
			--ExpoEffect1RedDisappear:Play()


			task.wait()

			bomb:Destroy()

		end)

		if BombHandler then
			coroutine.resume(BombHandler)
		end
	

		return self

	end)

end


my main round script :

task.wait(.1)
local Seed = Random.new()

local PS = game:GetService("Players")
local SV = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SetAtt = ReplicatedStorage:WaitForChild("SetAttribute")
local visualsr = ReplicatedStorage:WaitForChild("VisualsRemote")
local soundsw = workspace:WaitForChild("Sounds")
local soundsingame = soundsw:WaitForChild("In-Game")
local gamemodules = ReplicatedStorage:WaitForChild("GameModules")
local bombSpawner = gamemodules:WaitForChild("BombSpawner")
local bombfunctions = bombSpawner:WaitForChild("AssignBombFunction")
local BombTypesFolder = bombfunctions:WaitForChild("BombTypes")

local gamevalues = ReplicatedStorage:WaitForChild("GameValues")
local roundtimeleft = gamevalues:WaitForChild("RoundTimeLeft")
local gamestarted = gamevalues:WaitForChild("GameStarted")
local currentIntensity = gamevalues:WaitForChild("CurrentIntensity")
local intermissionTime = gamevalues:WaitForChild("IntermissionTime")
local roundtimeStart = gamevalues:WaitForChild("roundTime")
local gamestatus = gamevalues:WaitForChild("GameStatus")
local modelsmanyfolder = SV:WaitForChild("ModelsMany")
local roundEndSting = soundsw:WaitForChild("roundEndSting")
local othersFolder = workspace:WaitForChild("Others")
local bombModels = SV:WaitForChild("BombModels")
local bombsfolderworks = workspace:WaitForChild("bombs")


local loadingmapborder = modelsmanyfolder:WaitForChild("LoadingMapBorders")

local mapFolder = ReplicatedStorage:WaitForChild("Maps")
local InGameMapsFolder = workspace:WaitForChild("MapsInGame")

local requirebombFunctions = require(bombfunctions)

local AddAttributes = {
	{name = "OnMenu", value = true},
	{name = "Survived", value = false},
	{name = "elpepe", value = false},


}

PS.PlayerAdded:Connect(function(player)
	for _, attribute in ipairs(AddAttributes) do
		player:SetAttribute(attribute.name, attribute.value)
	end
	player.CharacterAdded:Connect(function(character)
		local HealthValue = Instance.new("NumberValue")
		local MaxHealthValue = Instance.new("NumberValue")

		MaxHealthValue.Parent = character
		MaxHealthValue.Name = "MaxHealth"
		MaxHealthValue.Value = 100

		HealthValue.Parent = character
		HealthValue.Name = "HealthV"
		HealthValue.Value = 100
		HealthValue:GetPropertyChangedSignal("Value"):Connect(function()
			if HealthValue then
				if HealthValue.Value <= 0 then
					HealthValue.Value = 0
					character:BreakJoints()
				end
			end
		end)
	end)
end)


task.wait(5)

--local intermission = intermissionTime
--local round = 45
local players = {}
local activePlayers = {}
local connections = {}
local roundDebounce = false


local currentMap = nil
local currentbombSpawnerPart = nil
local PlayersToCheck = 1
local DefaultLobbyTime = 35 -- 135
local DefaultGameTime = 200-- 200
local Getplayers = #PS:GetPlayers()
local roundtimeCoroutine = nil
local spawnBombsLoop = nil

local activeBombs = {}

local newbombspawner = othersFolder:WaitForChild("BombSpawner")

local Region = newbombspawner

function FormatSeconds(Secondss)
	local Seconds = Secondss
	local minutes = math.floor(Seconds / 60)
	local secondsRemaining = Seconds % 60
	return string.format("%d:%02d", minutes, secondsRemaining)
end

local function removePlayer(player)
	local playerFound = table.find(activePlayers, player)
	if (playerFound) then
		table.remove(activePlayers, playerFound)
		connections[player.UserId.."Left"]:Disconnect()
		connections[player.UserId.."Died"]:Disconnect()
		if (#activePlayers == 0) then
			if gamestarted.Value then
				gamestarted.Value = false
			end
		end
	end
end

function checkPlayersAmount(amount)
	Getplayers = #PS:GetPlayers()
	task.wait(.1)

	for _, player in pairs(PS:GetPlayers()) do
		if player then
			if Getplayers >= 1 then
				if player:GetAttribute("OnMenu") == true then
					return false
				end
			end
		end
	end

	if Getplayers >= amount then
		if not gamestarted.Value then
			--print("Mas o Igual de Jugadores")
			return true
		end
	elseif Getplayers < amount then
		--if not InLobby.Value then
		--print("Menos de Jugadores, La Partida no comenzara")
		return false
		--end

	end

	if Getplayers <= 0 then	
		warn("No Hay Nadie en El Servidor, Checkeando Infinitamente.")
	end

end

function SearchIn(folder : Folder , name : string, selectRandom : boolean)
	if folder and folder:IsA("Folder") then
		if  selectRandom then
			local getChildren = folder:GetChildren()
			local choosenitem = getChildren[Seed:NextInteger(1, #getChildren)]
			if choosenitem then
				return choosenitem
			else
				return nil
			end
		end
	end
end

local totalParts = 0

local function LoadMap(prt, parent)

	if prt:IsA("Model") then
		if #prt:GetChildren() > 0 then
			print("Model:", prt.Name, "Children:", #prt:GetChildren())
			local newmodel = Instance.new("Model")
			newmodel.Name = prt.Name
			newmodel.Parent = parent


			local searched = 0
			for _, prtChild in pairs(prt:GetChildren()) do
				totalParts = totalParts+1
				if searched % 300 == 0 then task.wait() end searched = searched + 1

				LoadMap(prtChild, newmodel)
			end
		end
	elseif prt:IsA("BasePart") or prt:IsA("MeshPart") or prt:IsA("Part") or prt:IsA("Union") then

		local cloneprt = prt:Clone()
		cloneprt.Anchored = true
		cloneprt.Parent = parent


		print("Cloned:", parent.Name)
	elseif prt:IsA("StringValue") then
		local cloneit = prt:Clone()
		cloneit.Parent = parent
	end

end

local function RemovePlayersTable()
	for i,v in ipairs(PS:GetPlayers()) do
		local char = v.Character
		local hum = char:FindFirstChildWhichIsA("Humanoid")

		if table.find(players, v.Name) then
			table.remove(players, table.find(players, v.Name))
		end
	end
end

local function CheckPlayers()
	--if checkPlayersAmount(PlayersToCheck) then

	for i,v in ipairs(PS:GetPlayers()) do
		local char = v.Character
		local hum = char:FindFirstChildWhichIsA("Humanoid")

		if not table.find(players, v.Name) then
			table.insert(players, v.Name)

			hum.Died:Connect(function()
				table.remove(players, table.find(players, v.Name))

				if #players == 0 then
					--gamestarted.Value = false
					--print("Everyone died")

				end
			end)
		end
	end
	--end
end

gamestarted.Value = false

function CleanBombs()

	
	for _, bombVariables in ipairs(activeBombs) do
		if bombVariables then
			bombVariables:DestroyBomb()
		end
	end
	
	task.wait(.1)
	
	activeBombs = {}
	
end

local bombFunctions = nil

local function RoundStart()

	if checkPlayersAmount(PlayersToCheck) then
		RemovePlayersTable()
		task.wait(0.15)
		for _, player in pairs(PS:GetPlayers()) do
			visualsr:FireClient(player, "stopRoundMusic")
		end

		for _, playerd in pairs(PS:GetPlayers()) do
			if (playerd) then
				local character = playerd.Character
				if (character:FindFirstChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")) then
					local hum = character:WaitForChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")
					if hum then
						if character:FindFirstChild("HealthV") then
							local healthValue = character:WaitForChild("HealthV")
							if healthValue:IsA("NumberValue") then
								healthValue.Value = 100
							end
						end
					end
				end
			end
		end

		CleanBombs() -- porseacaso

		spawnBombsLoop = coroutine.create(function()
			while true do

				task.wait(Seed:NextNumber(1, 10)*Seed:NextInteger(1, 1.5)/currentIntensity.Value + 1.35)

				local getbombsmodels = bombsfolderworks:GetChildren()
				local amountofmodels = #getbombsmodels
				if gamestarted.Value then
					if amountofmodels <= 15 then
						local x = newbombspawner.Position.X
						local z = newbombspawner.Position.Z

						local xS = newbombspawner.Size.X/2
						local zS = newbombspawner.Size.Z/2

						local pos1 = math.random(x-xS, x+xS)
						local pos2 = math.random(z-zS,z+zS)

						local rayOrigin = Vector3.new(pos1, newbombspawner.Position.Y, pos2)
						local rayDirection = Vector3.new(0, -500, 0)

						local raycasParams = RaycastParams.new()
						raycasParams.FilterType = Enum.RaycastFilterType.Exclude
						raycasParams.FilterDescendantsInstances = {newbombspawner}

						local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycasParams)

						if raycastResult then
							local randomSelect = SearchIn(bombModels, "", true)
							if randomSelect then
								if randomSelect:FindFirstChild("Model") then
									local ModelFolder = randomSelect:WaitForChild("Model")
									if ModelFolder then
										for _, models in pairs(ModelFolder:GetChildren()) do -- here i do the bomb spawning
											if models:IsA("Model") then
												local cloneBombModel = models:Clone()
												cloneBombModel.Parent = bombsfolderworks
												cloneBombModel:PivotTo(CFrame.new(raycastResult.Position + Vector3.new(0, Seed:NextNumber(50, 75), 0)))

												local bombfunctions = requirebombFunctions.createbomb(cloneBombModel)
												bombfunctions:assignFunction()
													
											end
										end
									end
								end
							end
						end
					else

					end
				else
					CleanBombs()
				end


			end
		end)

		--		gamestarted.Value = false


		intermissionTime.Value = DefaultLobbyTime
		gamestatus.Value = "Intermission : "..FormatSeconds(intermissionTime.Value)

		--RoundWait(intermissionTime.Value)
		task.wait(1.8)

		print("intermission started")

		for _, player in pairs(PS:GetPlayers()) do
			if player then
				player:SetAttribute("Survived", false)
				visualsr:FireClient(player, "playLobbyMusic")

			end
		end

		for i = DefaultLobbyTime, 0, -1 do
			if intermissionTime.Value >= 0 then
				intermissionTime.Value = i
				gamestatus.Value = "Intermission : "..FormatSeconds(intermissionTime.Value)
				--print(lobbytime.Value)
				task.wait(1)
			end
		end

		print("intermission ended")


		local getmaps = mapFolder:GetChildren()

		local selectedMapRandom = getmaps[Seed:NextInteger(#getmaps, 1)]

		gamestatus.Value = "Loading Map : "..selectedMapRandom.Name..".."
		local borderclone = loadingmapborder:Clone()
		borderclone.Parent = workspace


		LoadMap(selectedMapRandom, InGameMapsFolder)
		task.wait(.1)
		for _, getmaps in pairs(InGameMapsFolder:GetChildren()) do
			if getmaps:IsA("Model") or getmaps:IsA("BasePart") then
				currentMap = getmaps
			end
		end
		if currentMap then
			print(currentMap:GetFullName())
			local PartsToWeld = currentMap:GetDescendants()
			local WeldPart = currentMap:WaitForChild("Primary") -- Insert main part to weld
			local Whitelist = WeldPart.Name
			--------------------------------
			for i, part in pairs(PartsToWeld) do
				local Weld = Instance.new("WeldConstraint")
				local success, errormessage = pcall(function()
					if part.Name ~= "Primary" then
						if part:IsA("Part") or part:IsA("BasePart") then
							Weld.Parent = part
							Weld.Name = "AutoWeld"
							Weld.Part0 = part
							Weld.Part1 = WeldPart
							if part.Name == Whitelist then 
								Weld.Part1 = script.Parent:FindFirstAncestorWhichIsA("Part")
							end
							part.Anchored = false
						end
					end
				end)
				if errormessage then
					warn("refWeld :: Error welding Part")
				end
			end
		end

		borderclone:Destroy()

		gamestatus.Value = "Starting Round "

		task.wait(2) -- loading map time

		CheckPlayers()

		print("round started")
		gamestatus.Value = ""
		gamestarted.Value = true
		task.wait(1.25)

		for _, playerd in pairs(PS:GetPlayers()) do
			if (playerd) then
				local character = playerd.Character
				if (character:FindFirstChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")) then
					local hum = character:WaitForChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")
					if hum then
						if playerd:GetAttribute("OnMenu") == false then
							if (hum.Health) > 0 then
								table.insert(activePlayers, playerd)

								connections[playerd.UserId.."Left"] = playerd.AncestryChanged:Connect(function()
									removePlayer(playerd)
								end)

								connections[playerd.UserId.."Died"] = hum.Died:Connect(function()
									removePlayer(playerd)
								end)


							end
						end
					end
				end
			end
		end

		for _, player in pairs(PS:GetPlayers()) do
			if player then
				if player:GetAttribute("OnMenu") == false then
					player:SetAttribute("Survived", true)
					local char = player.Character
					visualsr:FireClient(player, "showmaponce", tostring(currentMap.mapName.Value), tostring(currentMap.mapCreator.Value))
					local character = player.Character
					if (character:FindFirstChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")) then
						local hum = character:WaitForChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")
						if hum then
							if char:FindFirstChild("HumanoidRootPart") then
								hum.Jump = true
								local rootpart = char:WaitForChild("HumanoidRootPart")
								if currentMap:FindFirstChild("Primary") then
									rootpart.CFrame = currentMap.Primary.CFrame + Vector3.new(0.1, 2.5,  0)
								else
									rootpart.CFrame = currentMap:GetPivot() + Vector3.new(0.1, 1.4, 0)
								end

							end
						end
					end
				end
			end
		end


		local result = Seed:NextNumber(1, 5.05) 
		local convert = ("%.1f"):format(result) 
		local convertonumber = tonumber(convert) 
		if convertonumber > 5.0 then 
			convertonumber = 5.0 
		end 
		currentIntensity.Value = convertonumber  
		for _, player in pairs(PS:GetPlayers()) do
			visualsr:FireClient(player, "stopLobbyMusic")
		end
		workspace.Sounds["Bomb Fuse"]:Play()


		task.wait(3)

		for _, player in pairs(PS:GetPlayers()) do
			if (#activePlayers > 0) then
				visualsr:FireClient(player, "showIntensity")
			end
		end

		task.wait(4.2) -- wait for everything again

		roundtimeleft.Value = DefaultGameTime


		task.wait(.1)

		if spawnBombsLoop then
			coroutine.resume(spawnBombsLoop)
		end

		--roundtimeCoroutine = coroutine.create(function()
		print(table.unpack(activePlayers))

		for i = DefaultGameTime, 0, -1 do


			if roundtimeleft.Value >= 0 then
				roundtimeleft.Value = i
				--print(lobbytime.Value)
				task.wait(1)
			end

			if (#activePlayers == 0) then
				break
			end
			if roundtimeleft.Value <= 0 then
				roundtimeleft.Value = 0 
			end

		end
		print("round ended")

		for _, players in pairs(activePlayers) do
			if players then 
				if players.Character then
					if players.Character:FindFirstChild("HumanoidRootPart") then
						players.leaderstats.Insacoins.Value += 100
						players.leaderstats.Survivals.Value += 1
					end
				end
			end
		end
	end

	task.wait(.1)
	for _, remainingPlayer in pairs(activePlayers) do
		warn("round ended")
	end

	for _, connection in pairs(connections) do
		connection:Disconnect()
	end
	table.clear(activePlayers)
	if currentMap then
		currentMap:Destroy()
	end

	if spawnBombsLoop then
		coroutine.close(spawnBombsLoop)
	end
	task.wait(.1)
	CleanBombs()

	gamestarted.Value = false

	task.spawn(function()
		for _, player in pairs(PS:GetPlayers()) do
			if player then
				if player:GetAttribute("OnMenu") == false then
					player:SetAttribute("Survived", true)
					local char = player.Character
					local character = player.Character
					if (character:FindFirstChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")) then
						local hum = character:WaitForChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")
						if hum then
							if char:FindFirstChild("HumanoidRootPart") then
								hum.Jump = true
								local rootpart = char:WaitForChild("HumanoidRootPart")
								rootpart.Anchored = true
								task.wait(1.29)
								rootpart.Anchored = false
								rootpart.CFrame = CFrame.new(99.8232346, 4.5999999, -190.378067, 1, 0, 0, 0, 1, 0, 0, 0, 1) + Vector3.new(0.1, 1.4, 0)

							end
						end
					end
				end
			end
		end
	end)
	roundEndSting:Play()


	task.spawn(function()
		task.delay(0.25, function()
			for _, player in pairs(PS:GetPlayers()) do
				visualsr:FireClient(player, "stopRoundMusic")
			end
		end)
	end)


	task.wait(1)
	--	print("ended")
	--end)
	--coroutine.resume(roundtimeCoroutine)


	--print("round ended")
	--RoundWait(roundtimeStart.Value)
end

gamestarted:GetPropertyChangedSignal("Value"):Connect(function()
	if not gamestarted.Value then
		if roundtimeCoroutine then
			coroutine.close(roundtimeCoroutine)
		end
	end
end)


task.spawn(function()
	while true do
		if roundDebounce == false then
			task.wait(1.5)
			RoundStart()
		end
	end
end)

Wait, Silly Mistake from me, I didn’t actually added the bombfunctions to the table, waittt

I don’t kinda get it , could u explain more?

so what require() does is more or less execute the module script. By requiring it once and assigning it to shared, the modulescript will only run once.

you can then modify any variables/tables within the modulescript using helper functions.

e.g:

local bombs = {}

local module = {}

function module.CreateBomb()
    -- blah blah create a bomb
end

function module.RemoveBomb(bombId: number)
    local bomb = bombs[bombId]
    if not bomb then return end
    bomb:Destroy() -- if you the bomb itself is an object that you created and has some sort of delete method, you should call that here.
    bombs[bombId] = nil
end


function module.ClearBombs()
    for i, v in pairs(bombs) do
        v:Destroy()
    end
    table.clear(bombs)
end


return module
2 Likes

Alright, so this error appears

image
image

give the script for full context also add me on roblox

1 Like

I am not. I was just informing him of the uses. All of them.

here

Round script :

task.wait(.1)
local Seed = Random.new()

local PS = game:GetService("Players")
local SV = game:GetService("ServerStorage")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SetAtt = ReplicatedStorage:WaitForChild("SetAttribute")
local visualsr = ReplicatedStorage:WaitForChild("VisualsRemote")
local soundsw = workspace:WaitForChild("Sounds")
local soundsingame = soundsw:WaitForChild("In-Game")
local gamemodules = ReplicatedStorage:WaitForChild("GameModules")
local bombSpawner = gamemodules:WaitForChild("BombSpawner")
local bombfunctions = bombSpawner:WaitForChild("AssignBombFunction")
local BombTypesFolder = bombfunctions:WaitForChild("BombTypes")

local gamevalues = ReplicatedStorage:WaitForChild("GameValues")
local roundtimeleft = gamevalues:WaitForChild("RoundTimeLeft")
local gamestarted = gamevalues:WaitForChild("GameStarted")
local currentIntensity = gamevalues:WaitForChild("CurrentIntensity")
local intermissionTime = gamevalues:WaitForChild("IntermissionTime")
local roundtimeStart = gamevalues:WaitForChild("roundTime")
local gamestatus = gamevalues:WaitForChild("GameStatus")
local modelsmanyfolder = SV:WaitForChild("ModelsMany")
local roundEndSting = soundsw:WaitForChild("roundEndSting")
local othersFolder = workspace:WaitForChild("Others")
local bombModels = SV:WaitForChild("BombModels")
local bombsfolderworks = workspace:WaitForChild("bombs")


local loadingmapborder = modelsmanyfolder:WaitForChild("LoadingMapBorders")

local mapFolder = ReplicatedStorage:WaitForChild("Maps")
local InGameMapsFolder = workspace:WaitForChild("MapsInGame")

local requirebombFunctions = require(bombfunctions)

local AddAttributes = {
	{name = "OnMenu", value = true},
	{name = "Survived", value = false},
	{name = "elpepe", value = false},


}

PS.PlayerAdded:Connect(function(player)
	for _, attribute in ipairs(AddAttributes) do
		player:SetAttribute(attribute.name, attribute.value)
	end
	player.CharacterAdded:Connect(function(character)
		local HealthValue = Instance.new("NumberValue")
		local MaxHealthValue = Instance.new("NumberValue")

		MaxHealthValue.Parent = character
		MaxHealthValue.Name = "MaxHealth"
		MaxHealthValue.Value = 100

		HealthValue.Parent = character
		HealthValue.Name = "HealthV"
		HealthValue.Value = 100
		HealthValue:GetPropertyChangedSignal("Value"):Connect(function()
			if HealthValue then
				if HealthValue.Value <= 0 then
					HealthValue.Value = 0
					character:BreakJoints()
				end
			end
		end)
	end)
end)


task.wait(5)

--local intermission = intermissionTime
--local round = 45
local players = {}
local activePlayers = {}
local connections = {}
local roundDebounce = false


local currentMap = nil
local currentbombSpawnerPart = nil
local PlayersToCheck = 1
local DefaultLobbyTime = 35 -- 135
local DefaultGameTime = 200-- 200
local Getplayers = #PS:GetPlayers()
local roundtimeCoroutine = nil
local spawnBombsLoop = nil

local activeBombs = {}

local newbombspawner = othersFolder:WaitForChild("BombSpawner")

local Region = newbombspawner

function FormatSeconds(Secondss)
	local Seconds = Secondss
	local minutes = math.floor(Seconds / 60)
	local secondsRemaining = Seconds % 60
	return string.format("%d:%02d", minutes, secondsRemaining)
end

local function removePlayer(player)
	local playerFound = table.find(activePlayers, player)
	if (playerFound) then
		table.remove(activePlayers, playerFound)
		connections[player.UserId.."Left"]:Disconnect()
		connections[player.UserId.."Died"]:Disconnect()
		if (#activePlayers == 0) then
			if gamestarted.Value then
				gamestarted.Value = false
			end
		end
	end
end

function checkPlayersAmount(amount)
	Getplayers = #PS:GetPlayers()
	task.wait(.1)

	for _, player in pairs(PS:GetPlayers()) do
		if player then
			if Getplayers >= 1 then
				if player:GetAttribute("OnMenu") == true then
					return false
				end
			end
		end
	end

	if Getplayers >= amount then
		if not gamestarted.Value then
			--print("Mas o Igual de Jugadores")
			return true
		end
	elseif Getplayers < amount then
		--if not InLobby.Value then
		--print("Menos de Jugadores, La Partida no comenzara")
		return false
		--end

	end

	if Getplayers <= 0 then	
		warn("No Hay Nadie en El Servidor, Checkeando Infinitamente.")
	end

end

function SearchIn(folder : Folder , name : string, selectRandom : boolean)
	if folder and folder:IsA("Folder") then
		if  selectRandom then
			local getChildren = folder:GetChildren()
			local choosenitem = getChildren[Seed:NextInteger(1, #getChildren)]
			if choosenitem then
				return choosenitem
			else
				return nil
			end
		end
	end
end

local totalParts = 0

local function LoadMap(prt, parent)

	if prt:IsA("Model") then
		if #prt:GetChildren() > 0 then
			print("Model:", prt.Name, "Children:", #prt:GetChildren())
			local newmodel = Instance.new("Model")
			newmodel.Name = prt.Name
			newmodel.Parent = parent


			local searched = 0
			for _, prtChild in pairs(prt:GetChildren()) do
				totalParts = totalParts+1
				if searched % 300 == 0 then task.wait() end searched = searched + 1

				LoadMap(prtChild, newmodel)
			end
		end
	elseif prt:IsA("BasePart") or prt:IsA("MeshPart") or prt:IsA("Part") or prt:IsA("Union") then

		local cloneprt = prt:Clone()
		cloneprt.Anchored = true
		cloneprt.Parent = parent


		print("Cloned:", parent.Name)
	elseif prt:IsA("StringValue") then
		local cloneit = prt:Clone()
		cloneit.Parent = parent
	end

end

local function RemovePlayersTable()
	for i,v in ipairs(PS:GetPlayers()) do
		local char = v.Character
		local hum = char:FindFirstChildWhichIsA("Humanoid")

		if table.find(players, v.Name) then
			table.remove(players, table.find(players, v.Name))
		end
	end
end

local function CheckPlayers()
	--if checkPlayersAmount(PlayersToCheck) then

	for i,v in ipairs(PS:GetPlayers()) do
		local char = v.Character
		local hum = char:FindFirstChildWhichIsA("Humanoid")

		if not table.find(players, v.Name) then
			table.insert(players, v.Name)

			hum.Died:Connect(function()
				table.remove(players, table.find(players, v.Name))

				if #players == 0 then
					--gamestarted.Value = false
					--print("Everyone died")

				end
			end)
		end
	end
	--end
end

gamestarted.Value = false

function CleanBombs()

	
	for _, bombVariables in ipairs(activeBombs:GetChildren()) do
		if bombVariables then
			bombVariables:DestroyBomb()
		end
	end
	
	task.wait(.1)
	
	activeBombs = {}
	
end

local bombFunctions = nil

local function RoundStart()

	if checkPlayersAmount(PlayersToCheck) then
		RemovePlayersTable()
		task.wait(0.15)
		for _, player in pairs(PS:GetPlayers()) do
			visualsr:FireClient(player, "stopRoundMusic")
		end

		for _, playerd in pairs(PS:GetPlayers()) do
			if (playerd) then
				local character = playerd.Character
				if (character:FindFirstChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")) then
					local hum = character:WaitForChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")
					if hum then
						if character:FindFirstChild("HealthV") then
							local healthValue = character:WaitForChild("HealthV")
							if healthValue:IsA("NumberValue") then
								healthValue.Value = 100
							end
						end
					end
				end
			end
		end

		CleanBombs() -- porseacaso

		spawnBombsLoop = coroutine.create(function()
			while true do

				task.wait(Seed:NextNumber(1, 10)*Seed:NextInteger(1, 1.5)/currentIntensity.Value + 1.35)

				local getbombsmodels = bombsfolderworks:GetChildren()
				local amountofmodels = #getbombsmodels
				if gamestarted.Value then
					if amountofmodels <= 15 then
						local x = newbombspawner.Position.X
						local z = newbombspawner.Position.Z

						local xS = newbombspawner.Size.X/2
						local zS = newbombspawner.Size.Z/2

						local pos1 = math.random(x-xS, x+xS)
						local pos2 = math.random(z-zS,z+zS)

						local rayOrigin = Vector3.new(pos1, newbombspawner.Position.Y, pos2)
						local rayDirection = Vector3.new(0, -500, 0)

						local raycasParams = RaycastParams.new()
						raycasParams.FilterType = Enum.RaycastFilterType.Exclude
						raycasParams.FilterDescendantsInstances = {newbombspawner}

						local raycastResult = workspace:Raycast(rayOrigin, rayDirection, raycasParams)

						if raycastResult then
							local randomSelect = SearchIn(bombModels, "", true)
							if randomSelect then
								if randomSelect:FindFirstChild("Model") then
									local ModelFolder = randomSelect:WaitForChild("Model")
									if ModelFolder then
										for _, models in pairs(ModelFolder:GetChildren()) do -- here i do the bomb spawning
											if models:IsA("Model") then
												local cloneBombModel = models:Clone()
												cloneBombModel.Parent = bombsfolderworks
												cloneBombModel:PivotTo(CFrame.new(raycastResult.Position + Vector3.new(0, Seed:NextNumber(50, 75), 0)))

												local bombfunctions = requirebombFunctions.createbomb(cloneBombModel)
												bombfunctions:assignFunction()
												table.insert(activeBombs, bombfunctions)

													
											end
										end
									end
								end
							end
						end
					else

					end
				else
					CleanBombs()
				end


			end
		end)

		--		gamestarted.Value = false


		intermissionTime.Value = DefaultLobbyTime
		gamestatus.Value = "Intermission : "..FormatSeconds(intermissionTime.Value)

		--RoundWait(intermissionTime.Value)
		task.wait(1.8)

		print("intermission started")

		for _, player in pairs(PS:GetPlayers()) do
			if player then
				player:SetAttribute("Survived", false)
				visualsr:FireClient(player, "playLobbyMusic")

			end
		end

		for i = DefaultLobbyTime, 0, -1 do
			if intermissionTime.Value >= 0 then
				intermissionTime.Value = i
				gamestatus.Value = "Intermission : "..FormatSeconds(intermissionTime.Value)
				--print(lobbytime.Value)
				task.wait(1)
			end
		end

		print("intermission ended")


		local getmaps = mapFolder:GetChildren()

		local selectedMapRandom = getmaps[Seed:NextInteger(#getmaps, 1)]

		gamestatus.Value = "Loading Map : "..selectedMapRandom.Name..".."
		local borderclone = loadingmapborder:Clone()
		borderclone.Parent = workspace


		LoadMap(selectedMapRandom, InGameMapsFolder)
		task.wait(.1)
		for _, getmaps in pairs(InGameMapsFolder:GetChildren()) do
			if getmaps:IsA("Model") or getmaps:IsA("BasePart") then
				currentMap = getmaps
			end
		end
		if currentMap then
			print(currentMap:GetFullName())
			local PartsToWeld = currentMap:GetDescendants()
			local WeldPart = currentMap:WaitForChild("Primary") -- Insert main part to weld
			local Whitelist = WeldPart.Name
			--------------------------------
			for i, part in pairs(PartsToWeld) do
				local Weld = Instance.new("WeldConstraint")
				local success, errormessage = pcall(function()
					if part.Name ~= "Primary" then
						if part:IsA("Part") or part:IsA("BasePart") then
							Weld.Parent = part
							Weld.Name = "AutoWeld"
							Weld.Part0 = part
							Weld.Part1 = WeldPart
							if part.Name == Whitelist then 
								Weld.Part1 = script.Parent:FindFirstAncestorWhichIsA("Part")
							end
							part.Anchored = false
						end
					end
				end)
				if errormessage then
					warn("refWeld :: Error welding Part")
				end
			end
		end

		borderclone:Destroy()

		gamestatus.Value = "Starting Round "

		task.wait(2) -- loading map time

		CheckPlayers()

		print("round started")
		gamestatus.Value = ""
		gamestarted.Value = true
		task.wait(1.25)

		for _, playerd in pairs(PS:GetPlayers()) do
			if (playerd) then
				local character = playerd.Character
				if (character:FindFirstChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")) then
					local hum = character:WaitForChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")
					if hum then
						if playerd:GetAttribute("OnMenu") == false then
							if (hum.Health) > 0 then
								table.insert(activePlayers, playerd)

								connections[playerd.UserId.."Left"] = playerd.AncestryChanged:Connect(function()
									removePlayer(playerd)
								end)

								connections[playerd.UserId.."Died"] = hum.Died:Connect(function()
									removePlayer(playerd)
								end)


							end
						end
					end
				end
			end
		end

		for _, player in pairs(PS:GetPlayers()) do
			if player then
				if player:GetAttribute("OnMenu") == false then
					player:SetAttribute("Survived", true)
					local char = player.Character
					visualsr:FireClient(player, "showmaponce", tostring(currentMap.mapName.Value), tostring(currentMap.mapCreator.Value))
					local character = player.Character
					if (character:FindFirstChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")) then
						local hum = character:WaitForChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")
						if hum then
							if char:FindFirstChild("HumanoidRootPart") then
								hum.Jump = true
								local rootpart = char:WaitForChild("HumanoidRootPart")
								if currentMap:FindFirstChild("Primary") then
									rootpart.CFrame = currentMap.Primary.CFrame + Vector3.new(0.1, 2.5,  0)
								else
									rootpart.CFrame = currentMap:GetPivot() + Vector3.new(0.1, 1.4, 0)
								end

							end
						end
					end
				end
			end
		end


		local result = Seed:NextNumber(1, 5.05) 
		local convert = ("%.1f"):format(result) 
		local convertonumber = tonumber(convert) 
		if convertonumber > 5.0 then 
			convertonumber = 5.0 
		end 
		currentIntensity.Value = convertonumber  
		for _, player in pairs(PS:GetPlayers()) do
			visualsr:FireClient(player, "stopLobbyMusic")
		end
		workspace.Sounds["Bomb Fuse"]:Play()


		task.wait(3)

		for _, player in pairs(PS:GetPlayers()) do
			if (#activePlayers > 0) then
				visualsr:FireClient(player, "showIntensity")
			end
		end

		task.wait(4.2) -- wait for everything again

		roundtimeleft.Value = DefaultGameTime


		task.wait(.1)

		if spawnBombsLoop then
			coroutine.resume(spawnBombsLoop)
		end

		--roundtimeCoroutine = coroutine.create(function()
		print(table.unpack(activePlayers))

		for i = DefaultGameTime, 0, -1 do


			if roundtimeleft.Value >= 0 then
				roundtimeleft.Value = i
				--print(lobbytime.Value)
				task.wait(1)
			end

			if (#activePlayers == 0) then
				break
			end
			if roundtimeleft.Value <= 0 then
				roundtimeleft.Value = 0 
			end

		end
		print("round ended")

		for _, players in pairs(activePlayers) do
			if players then 
				if players.Character then
					if players.Character:FindFirstChild("HumanoidRootPart") then
						players.leaderstats.Insacoins.Value += 100
						players.leaderstats.Survivals.Value += 1
					end
				end
			end
		end
	end

	task.wait(.1)
	for _, remainingPlayer in pairs(activePlayers) do
		warn("round ended")
	end

	for _, connection in pairs(connections) do
		connection:Disconnect()
	end
	table.clear(activePlayers)
	if currentMap then
		currentMap:Destroy()
	end

	if spawnBombsLoop then
		coroutine.close(spawnBombsLoop)
	end
	task.wait(.1)
	CleanBombs()

	gamestarted.Value = false

	task.spawn(function()
		for _, player in pairs(PS:GetPlayers()) do
			if player then
				if player:GetAttribute("OnMenu") == false then
					player:SetAttribute("Survived", true)
					local char = player.Character
					local character = player.Character
					if (character:FindFirstChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")) then
						local hum = character:WaitForChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid")
						if hum then
							if char:FindFirstChild("HumanoidRootPart") then
								hum.Jump = true
								local rootpart = char:WaitForChild("HumanoidRootPart")
								rootpart.Anchored = true
								task.wait(1.29)
								rootpart.Anchored = false
								rootpart.CFrame = CFrame.new(99.8232346, 4.5999999, -190.378067, 1, 0, 0, 0, 1, 0, 0, 0, 1) + Vector3.new(0.1, 1.4, 0)

							end
						end
					end
				end
			end
		end
	end)
	roundEndSting:Play()


	task.spawn(function()
		task.delay(0.25, function()
			for _, player in pairs(PS:GetPlayers()) do
				visualsr:FireClient(player, "stopRoundMusic")
			end
		end)
	end)


	task.wait(1)
	--	print("ended")
	--end)
	--coroutine.resume(roundtimeCoroutine)


	--print("round ended")
	--RoundWait(roundtimeStart.Value)
end

gamestarted:GetPropertyChangedSignal("Value"):Connect(function()
	if not gamestarted.Value then
		if roundtimeCoroutine then
			coroutine.close(roundtimeCoroutine)
		end
	end
end)


task.spawn(function()
	while true do
		if roundDebounce == false then
			task.wait(1.5)
			RoundStart()
		end
	end
end)

Bomb oop module :frowning:

-- spook 6/04/24
local Seed = Random.new()
local bombclass = {}
local Replicated = game:GetService("ReplicatedStorage")
local SV = game:GetService("ServerStorage")
local bombfolder = SV:WaitForChild("BombModels")
local terrain = workspace.Terrain
local debrisService = game:GetService("Debris")
local libraries = Replicated:WaitForChild("Libraries")
local Zonemod = libraries:WaitForChild("Zone")
local requireZone = require(Zonemod)
local AssetsFolder = script:WaitForChild("Assets", 999)
local effectshandlerpart = AssetsFolder:WaitForChild("effectsHandler")
local TemporalFolder = workspace:WaitForChild("Temporal")
local collectionService = game:GetService("CollectionService")

local runSd = Replicated:WaitForChild("RunServiceTween")
local tPlus = Replicated:WaitForChild("TweenServicePlus")
local easyclientT = Replicated:WaitForChild("EasyClientTween")
local ReplicatedTweening = Replicated:WaitForChild("ReplicatedTweening")

local requireEasyTween = require(easyclientT)
local requireRunServ = require(runSd)
local requiretPlus = require(tPlus)
local requireTV2 = require(ReplicatedTweening)

local BombVisualRemote = Replicated:WaitForChild("BombVisual")


-- // ASSETS ZONE // --

local tickhighlight = AssetsFolder:WaitForChild("tickhighlight")
local tickeffectAttachment = effectshandlerpart:WaitForChild("tickeffect")
local explosionEffectAttachment = effectshandlerpart:WaitForChild("explosionEffect")
local explosionEffect2Attachment = effectshandlerpart:WaitForChild("explosioneffect2")
local ExpoEffect1Yellow = AssetsFolder:WaitForChild("expo1")
local ExpoEffect2Red = AssetsFolder:WaitForChild("expo2")


--///////////////////

local BombHandler = nil
local VerifyBombModel = nil

local BombClearEventHandler = nil

local settingsModule = {
	bombName = "classicbomb",
	TickTimeToExplode = 1.1,

	HitboxSize = Vector3.new(17, 17, 17.5),
	HitboxColor = Color3.fromRGB(173, 0, 0),
	HitboxTransparency = 0.5,
	HitboxOffset = Vector3.new(0, 0.1, 0),
	DebugHitbox = false,

	TimeToStartTicking = 5,
	DecreaseTickTimeCount = 0.2,
	TickSoundName = "",
	showHitbox = true,
	ExplosionSoundName = "",
	Damage = 10,
	DestroyWeldsChance = 50, -- porcentage 0.5
	DestroyPartsChance = 61, --porcentage 0.6
}

-- // Tween Information // --

local TweenInfos = {
	Expo1YellowSize = {TweenInfo.new(
		0.45,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut
		)},
	Expo1YellowTransparency = {TweenInfo.new(
		1,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut
		)},
	Expo2RedSize = {TweenInfo.new(
		0.55,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut
		)},
	Expo2RedTransparency = {TweenInfo.new(
		0.4,
		Enum.EasingStyle.Sine,
		Enum.EasingDirection.InOut
		)},
}

local goals = {
	Shrink = {
		Size = Vector3.new(0.000, 0.000, 0.000),
	},
	Disappear = {
		Transparency = 1
	}
}



--//////

function bombclass:RandomChance(tabla)
	local Sum = 0

	for _, Table in ipairs(tabla) do
		Sum += Table.Chance
	end

	local RNG = Random.new():NextInteger(1, Sum)

	local Weight = 0

	for _, Table in ipairs(tabla) do
		Weight += Table.Chance
		if Weight >= RNG then
			return Table.Rarity
		end
	end
end


function bombclass:SearchIn(folder : Folder , name : string, selectRandom : boolean)
	if folder and folder:IsA("Folder") then
		if not selectRandom then
			for _, objects in pairs(folder:GetChildren()) do
				if objects then
					if folder:FindFirstChild(settingsModule.TickSoundName) then
						local getItem = folder:WaitForChild(settingsModule.TickSoundName)
						if getItem then
							return getItem
						end
					else
						return nil
					end
				end

			end
		else
			local getChildren = folder:GetChildren()
			local choosenitem = getChildren[Seed:NextInteger(1, #getChildren)]
			if choosenitem then
				return choosenitem
			else
				return nil
			end
		end
	end
end

function bombclass:EmitFromAttachment(attachment, amount)
	if attachment:IsA("Attachment") then
		for _, particles in pairs(attachment:GetChildren()) do
			if particles:IsA("ParticleEmitter") then
				particles:Emit(amount)
			end
		end
	end
end

function bombclass:DisableParticlesFromAttachment(attachment)
	if attachment:IsA("Attachment") then
		for _, particles in pairs(attachment:GetDescendants()) do
			if particles:IsA("ParticleEmitter") then
				particles.Enabled = false
			end
		end
	end
end

function bombclass:EnableFromAttachment(attachment : Attachment, duration : number)
	task.spawn(function()
		if attachment:IsA("Attachment") then
			for _, particles in pairs(attachment:GetChildren()) do
				if particles:IsA("ParticleEmitter") then
					if duration then
						particles.Enabled = true
						task.delay(duration, function()
							particles.Enabled = false
						end)
					else
						particles.Enabled = true
					end
				end
			end
		end
	end)
end


function bombclass:DestroyBomb()
	if self.VerifyBombModel then
		self.VerifyBombModel:Destroy()
		-- make visual effects when destroying bomb, etc., here
	end
end


return function(bomb, selectedTag : string)
	task.spawn(function()
		local self = {}

		setmetatable(self, bombclass)


		self.bombModelVerify = bomb
		VerifyBombModel = self.bombModelVerify

		-- // Search folders
		self.specifiedBombFolder = nil
		self.SoundsFolderBomb = nil
		self.tickSoundsFolder = nil
		self.explosionsSoundFolder = nil
		-- /////

		self.settings = settingsModule


		self.CurrentTickSoundAttachment = nil
		self.CurrentTickSound = nil

		self.CurrentExplosionSoundAttachment = nil
		self.CurrentExplosionSound = nil
		self.Chances_1 = nil

		self.bombmeshorpart = nil



		if bomb:IsA("Model") then
			for _, bombparts in pairs(bomb:GetDescendants()) do
				if bombparts:FindFirstChild("IsBombPart") then
					local isbombpart = bombparts:WaitForChild("IsBombPart")
					if isbombpart:IsA("RayValue") then
						self.bombmeshorpart = bombparts
					end
				end
			end
		else
			self.bombmeshorpart = bomb
		end

		-- Put Assets .self here --
		task.wait()

		self.tickhighlight = nil
		self.tickattacheffect = nil
		self.bombExpEffectAttach = nil
		self.bombExpEffect2Attach = nil
		self.expoEffect1Yellow = nil
		self.expoEffect2Red = nil

		if self.bombmeshorpart then

			print(self.bombmeshorpart.Name)

			self.tickhighlight = tickhighlight:Clone()
			self.tickhighlight.Enabled = false

			self.tickattacheffect = tickeffectAttachment:Clone()

			self.tickhighlight.Parent = self.bombmeshorpart
			self.tickattacheffect.Parent = self.bombmeshorpart
			self.tickattacheffect.WorldCFrame = self.bombmeshorpart.CFrame
			bombclass:DisableParticlesFromAttachment(self.tickattacheffect)

			self.bombExpEffectAttach = explosionEffectAttachment:Clone()
			self.bombExpEffectAttach.Parent = self.bombmeshorpart
			self.bombExpEffectAttach.WorldCFrame = self.bombmeshorpart.CFrame		
			bombclass:DisableParticlesFromAttachment(self.bombExpEffectAttach)

			self.bombExpEffect2Attach = explosionEffect2Attachment:Clone()
			self.bombExpEffect2Attach.Parent = self.bombmeshorpart
			self.bombExpEffect2Attach.WorldCFrame = self.bombmeshorpart.CFrame		
			bombclass:DisableParticlesFromAttachment(self.bombExpEffect2Attach)

		else
			warn(" no set")
		end

		--////

		self.CurrentTime = self.settings["TickTimeToExplode"]


		if bombfolder:FindFirstChild(selectedTag) then
			self.specifiedBombFolder = bombfolder:WaitForChild(selectedTag)
			self.SoundsFolderBomb = self.specifiedBombFolder:WaitForChild("Sounds")
			self.tickSoundsFolder = self.SoundsFolderBomb:WaitForChild("ticks")
			self.explosionsSoundFolder = self.SoundsFolderBomb:WaitForChild("Explosions")
		end


		warn(settingsModule or table.unpack(settingsModule))

		task.wait()

		task.wait(settingsModule["TimeToStartTicking"])

		
		local BombHandler = coroutine.create(function()
			for count = self.settings["DecreaseTickTimeCount"] , 10 do
				if VerifyBombModel then
					if self.bombmeshorpart ~= nil and bomb ~= nil then
						print(self.bombmeshorpart:GetFullName())
						self.CurrentTime -= .1

						if bomb:IsA("BasePart") or bomb:IsA("MeshPart") or bomb:IsA("Part") then
							if self.tickhighlight then
								self.tickhighlight.Enabled = false
							end

							bomb.Color = Color3.fromRGB(255, 255, 255)

							task.wait(self.CurrentTime)

							if self.tickhighlight then
								self.tickhighlight.Enabled = true
							end

							if self.tickattacheffect then
								task.spawn(function()
									bombclass:EmitFromAttachment(self.tickattacheffect, Seed:NextInteger(1, 10))
								end)
							end

							bomb.Color = Color3.fromRGB(255, 0, 0)
						else


							if self.tickhighlight then
								self.tickhighlight.Enabled = false
							end


							task.wait(self.CurrentTime)

							if self.tickhighlight then
								self.tickhighlight.Enabled = true
							end

							if self.tickattacheffect then
								task.spawn(function()
									bombclass:EmitFromAttachment(self.tickattacheffect, Seed:NextInteger(1, 10))
								end)
							end


						end


						if self.specifiedBombFolder then
							if (settingsModule["TickSoundName"] == "") or (settingsModule["TickSoundName"] == nil) then
								local searchForSound = bombclass:SearchIn(self.tickSoundsFolder, nil, true)
								if searchForSound then
									self.CurrentTickSoundAttachment = Instance.new("Attachment")
									self.CurrentTickSoundAttachment.Parent = terrain
									if bomb:IsA("Part") or bomb:IsA("BasePart") or bomb:IsA("MeshPart") then
										self.CurrentTickSoundAttachment.CFrame = bomb.CFrame 
									else
										self.CurrentTickSoundAttachment.CFrame = bomb:GetPivot()
									end

									self.CurrentTickSound = searchForSound:Clone()
									self.CurrentTickSound.Parent = self.CurrentTickSoundAttachment
									self.CurrentTickSound:Play()
									debrisService:AddItem(self.CurrentTickSoundAttachment, self.CurrentTickSound.TimeLength)
								end
							else
								local searchForSound = bombclass:SearchIn(self.tickSoundsFolder, settingsModule["TickSoundName"], false)
								if searchForSound then
									self.CurrentTickSoundAttachment = Instance.new("Attachment")
									self.CurrentTickSoundAttachment.Parent = terrain
									if bomb:IsA("Part") or bomb:IsA("BasePart") or bomb:IsA("MeshPart") then
										self.CurrentTickSoundAttachment.CFrame = bomb.CFrame 
									else
										self.CurrentTickSoundAttachment.CFrame = bomb:GetPivot()
									end
									self.CurrentTickSound = searchForSound:Clone()
									self.CurrentTickSound.Parent = self.CurrentTickSoundAttachment
									self.CurrentTickSound:Play()
									debrisService:AddItem(self.CurrentTickSoundAttachment, self.CurrentTickSound.TimeLength)
								end
							end
						end

						task.wait(self.CurrentTime)
					end
				end
			end


			if self.tickattacheffect then
				self.tickattacheffect.Parent =	self.bombmeshorpart
				if self.bombmeshorpart then
					self.tickattacheffect.WorldCFrame = self.bombmeshorpart.CFrame
					debrisService:AddItem(self.tickattacheffect, 1.5)
				end
			end
			if self.bombExpEffectAttach then
				self.bombExpEffectAttach.Parent = terrain
				self.bombExpEffectAttach.WorldCFrame = self.bombmeshorpart.CFrame
				if self.bombmeshorpart then
					self.bombExpEffectAttach.WorldCFrame = self.bombmeshorpart.CFrame
					debrisService:AddItem(self.bombExpEffectAttach, 1.5)
				end
			end

			if self.bombExpEffect2Attach then
				self.bombExpEffect2Attach.Parent = terrain
				self.bombExpEffect2Attach.WorldCFrame = self.bombmeshorpart.CFrame
				if self.bombmeshorpart then
					self.bombExpEffect2Attach.WorldCFrame = self.bombmeshorpart.CFrame
					debrisService:AddItem(self.bombExpEffect2Attach, 1.5)
				end
			end

			if self.tickhighlight then
				self.tickhighlight:Destroy()
			end

			if self.bombExpEffect2Attach then
				bombclass:EmitFromAttachment(self.bombExpEffect2Attach, Seed:NextInteger(5 , 11))
			end
			if self.bombExpEffectAttach then
				bombclass:EnableFromAttachment(self.bombExpEffectAttach, 0.4)
			end

			self.expoEffect1Yellow = ExpoEffect1Yellow:Clone()
			self.expoEffect2Red = ExpoEffect2Red:Clone()

			if self.expoEffect1Yellow then
				self.expoEffect1Yellow.Parent = TemporalFolder
				self.expoEffect1Yellow.CFrame = self.bombmeshorpart.CFrame + Vector3.new(0,0.4,0)


			end
			if self.expoEffect2Red then
				self.expoEffect2Red.Parent = TemporalFolder
				self.expoEffect2Red.CFrame = self.bombmeshorpart.CFrame + Vector3.new(0,0.4,0)

				self.expoEffect2Red.Size = self.expoEffect1Yellow.Size + Vector3.new(0.55, 0.55, 0.55)

			end	

			task.wait(.1)

			--local ExpoEffect1YellowShrink = requireTV2:GetTweenObject(self.expoEffect1Yellow, TweenInfo.new(0.45, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Size = Vector3.new(0,0,0)})
			local ExpoEffect1YellowTransparency = requireTV2:GetTweenObject(self.expoEffect1Yellow, TweenInfo.new(1, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Transparency = 1})

			--local ExpoEffect2RedShrink = requireTV2:GetTweenObject(self.expoEffect2Red, TweenInfo.new(0.55, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Size = Vector3.new(0,0,0)})
			local ExpoEffect2RedTransparency = requireTV2:GetTweenObject(self.expoEffect2Red, TweenInfo.new(0.4, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut), {Transparency = 1})

			local ExpoEffect1YellowShrink_ = requiretPlus.Construct(
				self.expoEffect1Yellow,
				self.expoEffect1Yellow,
				TweenInfo.new(
					0.45,
					Enum.EasingStyle.Sine,
					Enum.EasingDirection.InOut
				),
				{
					Size = Vector3.new(0,0,0)
				}


			)



			local ExpoEffect2RedShrink_ = requiretPlus.Construct(
				self.expoEffect2Red,
				self.expoEffect2Red,
				TweenInfo.new(
					0.55,
					Enum.EasingStyle.Sine,
					Enum.EasingDirection.InOut
				),
				{
					Size = Vector3.new(0,0,0)
				}


			)

			ExpoEffect1YellowShrink_:Play()
			ExpoEffect2RedShrink_:Play()

			--ExpoEffect2RedShrink:Play()
			ExpoEffect2RedTransparency:Play()

			--ExpoEffect1YellowShrink:Play()
			ExpoEffect1YellowTransparency:Play()

			debrisService:AddItem(self.expoEffect2Red, 1.5)
			debrisService:AddItem(self.expoEffect1Yellow, 1.6)

			if (settingsModule["ExplosionSoundName"] == "") or (settingsModule["ExplosionSoundName"] == nil) then
				local searchForSound = bombclass:SearchIn(self.explosionsSoundFolder, nil, true)
				if searchForSound then
					self.CurrentExplosionSoundAttachment = Instance.new("Attachment")
					self.CurrentExplosionSoundAttachment.Parent = terrain
					if bomb:IsA("Part") or bomb:IsA("BasePart") or bomb:IsA("MeshPart") then
						self.CurrentExplosionSoundAttachment.CFrame = bomb.CFrame 
					else
						self.CurrentExplosionSoundAttachment.CFrame = bomb:GetPivot()
					end

					self.CurrentExplosionSound = searchForSound:Clone()
					self.CurrentExplosionSound.Parent = self.CurrentExplosionSoundAttachment
					self.CurrentExplosionSound:Play()
					debrisService:AddItem(self.CurrentExplosionSound, self.CurrentExplosionSound.TimeLength)
					debrisService:AddItem(self.CurrentExplosionSoundAttachment, self.CurrentExplosionSound.TimeLength + 0.1)
				end
			else
				local searchForSound = bombclass:SearchIn(self.explosionsSoundFolder, settingsModule["ExplosionSoundName"], false)
				if searchForSound then
					self.CurrentExplosionSoundAttachment = Instance.new("Attachment")
					self.CurrentExplosionSoundAttachment.Parent = terrain
					if bomb:IsA("Part") or bomb:IsA("BasePart") or bomb:IsA("MeshPart") then
						self.CurrentExplosionSoundAttachment.CFrame = bomb.CFrame 
					else
						self.CurrentExplosionSoundAttachment.CFrame = bomb:GetPivot()
					end
					self.CurrentExplosionSound = searchForSound:Clone()
					self.CurrentExplosionSound.Parent = self.CurrentExplosionSoundAttachment
					self.CurrentExplosionSound:Play()
					debrisService:AddItem(self.CurrentExplosionSound, self.CurrentExplosionSound.TimeLength)
					debrisService:AddItem(self.CurrentExplosionSoundAttachment, self.CurrentExplosionSound.TimeLength + 0.1)
				end
			end

			local SphereHitbox = Instance.new("Part")
			SphereHitbox.Shape = Enum.PartType.Ball
			SphereHitbox.Parent = TemporalFolder
			SphereHitbox.Size = self.settings["HitboxSize"]
			SphereHitbox.Color = self.settings["HitboxColor"]
			SphereHitbox.CanCollide = false

			if self.settings["DebugHitbox"] == true then
				SphereHitbox.Transparency = self.settings["HitboxTransparency"] or 0.5
			else
				SphereHitbox.Transparency = 1
			end

			SphereHitbox.Anchored = true
			SphereHitbox.CFrame = self.bombmeshorpart.CFrame + self.settings["HitboxOffset"]

			local ZoneContainer = requireZone.new(SphereHitbox)

			local getthem = ZoneContainer:getParts()

			self.Chances_1 = {
				{Rarity = "DestroyWeld",     Chance = self.settings["DestroyWeldsChance"]};
				{Rarity = "DestroyPart",    Chance = self.settings["DestroyPartsChance"]};
			}

			ZoneContainer.playerEntered:Connect(function(player)
				if player then
					if player.Character then
						local character = player.Character
						if character then
							if character:FindFirstChild("Humanoid") or character:FindFirstChildWhichIsA("Humanoid") then
								local humanoid = character:WaitForChild("Humanoid") or character("Humanoid")
								if humanoid then
									if character:FindFirstChild("HealthV") then
										local healthValue = character:WaitForChild("HealthV")
										if healthValue:IsA("NumberValue") then
											healthValue.Value -= self.settings["Damage"]
										end
									end
								end
							end
						end
					end
				end
			end)

			if getthem then
				for _, part in pairs(getthem) do
					local tags = collectionService:GetTags(part)
					if not (part == SphereHitbox) then
						if not (part.Name == self.expoEffect1Yellow.Name) or (part.Name == self.expoEffect2Red.Name) then
							print(getthem)
							--if part.Name == "HumanoidRootPart" then
							--local parent = part.Parent
							--if parent:FindFirstChild("Humanoid") or parent:FindFirstChildWhichIsA("Humanoid") then
							--local humanoid = parent:WaitForChild("Humanoid") or parent:FindFirstChildWhichIsA("Humanoid")
							--if humanoid then
							--	if parent:FindFirstChild("HealthV") then
							--	local healthValue = parent:WaitForChild("HealthV")
							--if healthValue:IsA("NumberValue") then
							--	healthValue.Value -= self.settings["Damage"]
							--end
							--end
							--end
							--	end
							--end
							for _, tag in pairs(tags) do
								if tag then
									if tag == "candestroy" then
										if part:IsA("BasePart") or part:IsA("Part") then
											local IfRarity = bombclass:RandomChance(self.Chances_1)
											if IfRarity == "DestroyPart" then
												part:Destroy()
											elseif IfRarity == "DestroyWeld" then
												for _, welds in pairs(part:GetChildren()) do
													if welds then
														if welds:IsA("Weld") or welds:IsA("Motor6D") or welds:IsA("WeldConstraint") then
															welds:Destroy()
														end
													end
												end
											else
												warn("???!!!?!?!?! "..IfRarity)
											end
										end 
									end
								end
							end
						end
					end
				end
			end
			debrisService:AddItem(SphereHitbox, 0.3)	


			--BombVisualRemote:Fire( self.expoEffect1Yellow ,"tweenBombEffect1Yellow")
			--BombVisualRemote:Fire( self.expoEffect2Red ,"tweenBombEffect2Red")


			--local ExpoEffect1YellowShrink =
			--	requireEasyTween.new(
			--	self.expoEffect1Yellow, self.expoEffect1Yellow, TweenInfo.new(
			--	2, -- 0.45
			--	Enum.EasingStyle.Sine,
			--	Enum.EasingDirection.InOut
			--	)   ,goals["Shrink"]
			--)
			--local ExpoEffect1YellowDisappear = 
			--requireRunServ.Create(
			--	self.expoEffect1Yellow, self.expoEffect1Yellow,TweenInfo.new(
			--		2, -- 1
			--		Enum.EasingStyle.Sine,
			--		Enum.EasingDirection.InOut
			--	) , {Transparency = 1}
			--)
			--local ExpoEffect1RedShrink =
			--	requireRunServ.Create(
			--	self.expoEffect2Red, self.expoEffect2Red,TweenInfo.new(
			--		2, -- 0.55
			--		Enum.EasingStyle.Sine,
			--		Enum.EasingDirection.InOut
			--	) , goals["Shrink"]
			--)
			--local ExpoEffect1RedDisappear = 
			--requireRunServ.Create(
			--	self.expoEffect2Red, self.expoEffect2Red,TweenInfo.new(
			--	2, -- 0.4
			--	Enum.EasingStyle.Sine,
			--	Enum.EasingDirection.InOut
			--	) , {Transparency = 1}
			--	)


			--	tweenObject:TweenAllClients(self.expoEffect2Red, {
			--	TweenInfo.new(0.55, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)}, {Size = Vector3.new(0.000, 0.000, 0.000)}
			--)
			--	tweenObject:TweenAllClients(self.expoEffect2Red, {
			--	TweenInfo.new(0.4, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut)}, {Transparency = 1}
			--)

			--ExpoEffect1YellowShrink:Play()
			--ExpoEffect1YellowDisappear:Play()

			--ExpoEffect1RedShrink:Play()
			--ExpoEffect1RedDisappear:Play()


			task.wait()

			bomb:Destroy()

		end)

		if BombHandler then
			coroutine.resume(BombHandler)
		end
	

		return self

	end)

end


I usually have a single script that loads all modules.
This allows me to easily communicate with module scripts and void using BindableEvents and BindableFunctions.
You can even create global values with this.

1 Like

In BombFunctions, you could have something like:

local BombFunctions = {}

function BombFunctions.Explode()
    print("Boom!")
    -- Explosion logic here
end

return BombFunctions

2. Requiring the Module in Other Scripts

For example, to use BombFunctions in a server script:

local ReplicatedStorage = game:GetService("ReplicatedStorage")
local BombFunctions = require(ReplicatedStorage:WaitForChild("BombFunctions"))

BombFunctions.Explode() -- Calls the Explode function from the module

3. Organizing Your Modules

If you have multiple modules, keep them organized in a folder within ReplicatedStorage for easy access and maintenance. For instance, a folder named GameModules can contain all your game’s module scripts like BombFunctions, PlayerStats, etc.

4. Sharing Data Between Modules

If modules need to share data (e.g., game settings, shared utilities), you can create a shared module that holds this data and require it in your other modules as needed.

For shared data or functions:

-- SharedModule.lua
local SharedModule = {
    GameVersion = "1.0.0",
    IsDebugMode = true,
}

function SharedModule.PrintDebug(message)
    if SharedModule.IsDebugMode then
        print(message)
    end
end

return SharedModule

Then, in another module or a script:

local SharedModule = require(ReplicatedStorage:WaitForChild("SharedModule"))

print(SharedModule.GameVersion) -- Access shared data
SharedModule.PrintDebug("Testing debug print") -- Use shared functions