Hello developers, I need help. I am creating a remake of the game Mega Boss Survival (By @Dinpey).
What Is This?
“Mega Boss Survival” is a popular game on Roblox created by the developer @Dinpey. In this game, players face off against powerful bosses in a survival setting, where they must work together with others to defeat these formidable enemies. The gameplay typically involves strategic planning, teamwork, and the use of various weapons and tools to survive and conquer the bosses. If the current player survives the boss, then he gets a certain number of points and one survival. And if he doesn’t survive, he gets nothing.
Problem:
When a player survives, he does not get points and survival, while for some reason it does not work for a certain number of bosses, that is, some give points and survival, while others do not.
Each boss has an Attribute for a certain number of points (NumberValue) and an Attribute for a certain amount of time, how long he will be in the workspace (NumberValue) (All bosses are in a folder in the ServerStorage!)
Bosses appear randomly with intermission 20 seconds
ALSO BOSS DISAPPEARING BEFORE THEN TIMER IS ENDS! (Like 2-3 second left and boss just disappear and function ends)
Script sequence:
Summary
Intermission/Countdown (20 seconds) → A random boss is selected → The boss is copied to the workspace (when Intermission/Countdown = 0) → The boss timer starts, which can have any value (from 0 seconds to infinity) → When the boss timer ends, two things happen:
→ The boss is removed from the workspace (Destroy() )
→ If the player survives the boss, then he gets a certain number of points and one survival, if not, then the player does not get anything.
After all this, the Intermission/Countdown (Cycle) starts again
Full Script for help:
Full Script
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerStorage = game:GetService("ServerStorage")
local Players = game:GetService("Players")
local tweenService = game:GetService("TweenService")
local IntermissionMusicEnabled = true
local DelayToStopTheIntermissionMusic = 1
local IntermissionMusicList={
1840684377,-- music name: Diamonds
1837066593,-- music name: Easy Mover
1842241530,-- music name: Lazy Sunday
1846458016,-- music name: No more
1840684208,-- music name: Playground Of The Stars (A)
1838857104,-- music name: Roselita
1845458027,-- music name: Smooth Nylons
1846457890,-- music name: Solitaire
1845756489,-- music name: Town Talk
11113863191,
}
local updateCountdownEvent = ReplicatedStorage:WaitForChild("UpdateCountdown")
local updateTimerEvent = ReplicatedStorage:WaitForChild("UpdateTimer")
local updateDifficulty = ReplicatedStorage:WaitForChild("UpdateDifficulty")
local TableName = {}
local countdownTime = 20 -- Changeable countdown time
local killersFolder = ServerStorage:WaitForChild("Killers")
--[[local function rewardSurvivors(points)
print(TableName)
for _, player in TableName do
if player and player.Character and player.Character:FindFirstChildOfClass("Humanoid") then
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local survivals = leaderstats:FindFirstChild("Survivals")
local playerPoints = leaderstats:FindFirstChild("Points")
if survivals and playerPoints then
survivals.Value = survivals.Value + 1
playerPoints.Value = playerPoints.Value + points
end
end
end
end
end-]]
local function rewardSurvivors(points)
print(TableName)
for _, player in TableName do
local Players = game:GetService("Players")
for _, player in Players:GetPlayers() do
if player and player.Character and player.Character:FindFirstChildOfClass("Humanoid") then
local leaderstats = player:FindFirstChild("leaderstats")
if leaderstats then
local survivals = leaderstats:FindFirstChild("Survivals")
local playerPoints = leaderstats:FindFirstChild("Points")
if survivals and playerPoints then
survivals.Value = survivals.Value + 1
playerPoints.Value = playerPoints.Value + points
end
end
end
end
end
end
local function spawnRandomKiller()
local killers = killersFolder:GetChildren()
if #killers == 0 then return end
local randomKiller = killers[math.random(1, #killers)]
local killerClone = randomKiller:Clone()
killerClone.Parent = workspace
local killerName = killerClone.Name
local killerTime = killerClone:GetAttribute("Time") or 30 -- Default time if not set
local killerPoints = killerClone:GetAttribute("Points") or 10 -- Default points if not set
local killerDifficulty = killerClone:GetAttribute("Difficulty") or 0
updateTimerEvent:FireAllClients(killerName, killerTime)
updateDifficulty:FireAllClients(killerDifficulty)
task.wait(killerTime)
rewardSurvivors(killerPoints)
warn("Rewarded!")
killerClone:Destroy()
end
local function startCountdown()
local music
if IntermissionMusicEnabled then
music=Instance.new("Sound",script)
music.SoundId = "rbxassetid://"..IntermissionMusicList[math.random(1,#IntermissionMusicList)]
music.Volume = 0.5
music.PlaybackSpeed = 0
music:Play()
local t = tweenService:Create(music, TweenInfo.new(DelayToStopTheIntermissionMusic),{PlaybackSpeed = 1})
t:Play()
end
for i = countdownTime, 0, -1 do
updateCountdownEvent:FireAllClients(i)
task.wait(1)
end
if IntermissionMusicEnabled then
local t = tweenService:Create(music, TweenInfo.new(DelayToStopTheIntermissionMusic),{PlaybackSpeed = 0})
t:Play()
t.Completed:Connect(function()
music:Destroy()
end)
end
spawnRandomKiller()
for _, player in Players:GetPlayers() do
if player and player.Character and player.Character:FindFirstChildOfClass("Humanoid") then
local Humanoid = player.Character:FindFirstChildOfClass("Humanoid")
if Humanoid.Health > 0 then
table.insert(TableName, player)
Humanoid.Died:Connect(function()
if table.find(TableName, player) then
for i, v in pairs(TableName) do
if v == player then
table.remove(TableName, i)
end
end
end
end)
end
end
end
end
while true do
TableName = {}
startCountdown()
end
I am a novice developer and programmer, therefore I am not strong in Luau and therefore the solution may be simple, but I just can't find it.