Alright this is highkey getting really aggravating at this point. My code works and doesn’t work at the same time. What’s supposed to happen is when you die you shouldn’t get any wins, the round shouldn’t get increased by one nor should there be multiple temporary shops for the player to buy from. I’m really hoping this post gets enough attention to at least battle this problem because this is a CRY FOR HELP. So please help me with this and maybe I’ll be able to actually have this game out by the deadline.
Code:
--//variables
local DS2 = require(1936396537)
local RF = game:GetService("ReplicatedFirst")
local RS = game:GetService("ReplicatedStorage")
local run = game:GetService("RunService")
local players = game:GetService("Players")
local zombs = RS:WaitForChild("Dummies")
local event = RS:WaitForChild("roundEvent")
local deathMsg = RS:WaitForChild("deathMsg")
local round = RS:WaitForChild("round").Value
local dumNum = RS:WaitForChild("dumNum").Value
local startTime = 30
local interlude = 15
local match = true
local dead = false
local win = false
local peds = game.Workspace:WaitForChild("Peds"):GetChildren()
local spawns = game.Workspace:WaitForChild("Ignored").spawnPoints
local spawnNums = spawns:GetChildren()
local status = game:GetService("ServerStorage").Status
players.PlayerAdded:Connect(function(plr)
local gui = plr:WaitForChild("PlayerGui")
local UI
for i, v in pairs(RF.UI:GetChildren()) do
local difUI = v:Clone()
difUI.Parent = gui
if difUI.Name == "MainUI" then
UI = difUI
end
end
--//spawning the player
RS.spawnPlr.OnServerEvent:Connect(function(plr)
plr:LoadCharacter()
match = true
end)
plr.CharacterAdded:Connect(function(char)
print("character added working")
local wins = DS2("wins", plr)
local points = plr.leaderstats:WaitForChild("Points")
local shopModel = RS.Shop.Models.tempShop
local shopClone = shopModel:Clone()
local function died()
match = false
status.Value = "Intermission"
round = 0
event:FireAllClients(round, status.Value)
task.wait(2)
points.Value = 0
for _,v in pairs(peds) do
v:Destroy()
end
startTime = 30
dumNum = 10
UI.zombsLeft.Text = ""
dead = true
if shopClone.Parent == game.Workspace then
shopClone:Destroy()
end
end
--//starting game
plr.CharacterAppearanceLoaded:Connect(function()
RS:WaitForChild("ammo"):FireClient(plr)
local hum = char:WaitForChild("Humanoid")
dead = false
status.Value = "Intermission"
UI.zombsLeft.Text = ""
run.Stepped:Connect(function()
hum.Died:Connect(function()
died()
end)
end)
while dead == false and match == true do
task.wait()
if plr:HasAppearanceLoaded() then
--// loads temporary shop for player
if status.Value == "Intermission" then
shopClone = shopModel:Clone()
shopClone.Parent = game.Workspace
task.wait(interlude)
shopClone:Destroy()
end
round += 1
event:FireAllClients(round, status.Value)
--//spawns in zombies
if dead ~= true and match == true then
for i = 0, dumNum-1, 1 do
local randSpawn = math.random(#spawnNums)
print(randSpawn)
local randTime = math.random(1,7)
local wTime = randTime / 10
local clone = zombs.Dummy:Clone()
print(wTime)
task.wait(wTime)
local rand = math.random(1, 5)
local spawnPoint = spawns:FindFirstChild(randSpawn)
clone.HumanoidRootPart.Position = spawnPoint.Position
clone.Parent = game.Workspace.Peds
if round >= 7 then
local tanky = zombs.Tanky:Clone()
if rand == 3 then
tanky.Parent = game.Workspace.Peds
tanky.HumanoidRootPart.Position = spawnPoint.Position
clone:Destroy()
end
elseif round >= 3 then
local speedy = zombs.Speedy:Clone()
if rand == 1 then
speedy.Parent = game.Workspace.Peds
speedy.HumanoidRootPart.Position = spawnPoint.Position
clone:Destroy()
end
end
end
else
break
end
--//makes player in round and increases amount of zombies for next round
status.Value = "Round"
event:FireAllClients(round, status.Value)
dumNum += 3
if status.Value == "Round" and dead ~= true then
print("got into round")
--//checks again if player has died during round
for i = startTime, 0, -1 do
peds = game.Workspace.Peds:GetChildren()
if status.Value == "Round" and dead == false then
UI.zombsLeft.Text = "Zombies left: "..#peds
if #peds == 0 then
status.Value = "Intermission"
event:FireAllClients(round, status.Value)
win = true
break
end
else
break
end
task.wait(1)
end
while not (#peds == 0) do
peds = game.Workspace.Peds:GetChildren()
event:FireAllClients("Over Time")
task.wait()
if #peds == 0 then
status.Value = "Intermission"
event:FireAllClients(round, status.Value)
win = true
break
end
UI.zombsLeft.Text = "Zombies left: "..#peds
end
if #peds == 0 then
status.Value = "Intermission"
event:FireAllClients(round, status.Value)
win = true
UI.zombsLeft.Text = ""
end
if status.Value == "Round" and dead == true then
break
else
status.Value = "Intermission"
event:FireAllClients(round, status.Value)
win = true
end
else
break
end
--//increases amount of time per round and wins
if win == true then
startTime += 15
wins:Increment(1)
win = false
print("player won")
end
end
end
end)
end)
end)
This is a video of what’s happening using roblox’s video recording cause I don’t feel like pulling out OBS (1.5 MB)
'Preciate the support if any (I know for a fact there won’t )
-Dza