So, In my game, I have separate tool packs. In the default tool pack, after some time, the trowel randomly disappears.
Nothing but the trowel disappears from the player’s backpack.
I haven’t tried much, which is why I’m coming here as a last resort.
I think it might be something to do with the round module script I have setup, but I’m not sure. The trowel tool is just the classic trowel by Roblox, and all of the scripts in there are fine. But it’s confusing me because the other three tools were fine. If it was the round script breaking, why are the other three tools not getting destroyed?
The other weird part is it always gets deleted when there are 4:37 remaining in the round. Every single time.
Videos:
The ONLY portion of the round script where tools get deleted (which is after the main round countdown, which is why I’m confused if it’s skipping code or not):
for i, player in pairs(Players:GetPlayers()) do
local character = player.Character
if not character then
continue
else
if character:FindFirstChild("GameTag") then
character.GameTag:Destroy()
end
for _, tool in pairs(player.Backpack:GetChildren()) do
if tool:IsA("Tool") then
tool:Destroy()
end
end
for _, tool in pairs(character:GetChildren()) do
if tool:IsA("Tool") then
tool:Destroy()
end
end
end
player:LoadCharacter()
end
The entire round module:
local Players = game:GetService("Players")
local replicatedStorage = game:GetService("ReplicatedStorage")
local lighting = game:GetService("Lighting")
local tweenService = game:GetService("TweenService")
local serverStorage = game:GetService("ServerStorage")
local soundService = game:GetService("SoundService")
local marketPlaceService = game:GetService("MarketplaceService")
local musicFolder = soundService:WaitForChild("GameMusic")
local otherSounds = soundService:WaitForChild("OtherSounds")
local maps = serverStorage:WaitForChild("MainGame"):WaitForChild("Maps")
local mainGame = replicatedStorage:WaitForChild("MainGame")
local remotes = mainGame:WaitForChild("Remotes")
local gameValues = mainGame:WaitForChild("GameValues")
local status = gameValues:WaitForChild("Status")
local cashReward = 75
local expReward = 50
local gamepasses = {
VIP = 123723006
}
local projectileTools = {
"Time Bomb"
}
local function toMS(s)
return ("%02i:%02i"):format(s/60%60, s%60)
end
local function unpackageTools(player, pack)
local clone = pack:Clone()
for _, tool in pairs(clone:GetChildren()) do
for __, Script in pairs(tool:GetDescendants()) do
if Script:IsA("Script") and Script.Enabled == false then
Script.Enabled = true
end
end
tool.Parent = player.Backpack
end
clone:Destroy()
end
local round = {}
function round.Waiting(numberOfPlayers, minimumPlayers)
status.Value = minimumPlayers.." ready players are required to start ("..numberOfPlayers.."/"..minimumPlayers.." players)"
end
function round.Intermission(intermissionTime)
for i=intermissionTime,0,-1 do
status.Value = "Intermission ("..i..")"
task.wait(1)
end
end
function round.StartRound(gameLength)
status.Value = ""
local plrs = {}
for i, player in pairs(Players:GetPlayers()) do
table.insert(plrs,player)
end
task.wait(2)
local availableSongs = soundService:WaitForChild("GameMusic"):GetChildren()
local chosenSong = availableSongs[math.random(1,#availableSongs)]
local availableMaps = maps:GetChildren()
local chosenMap = availableMaps[math.random(1,#availableMaps)]
status.Value = chosenMap.Name.." was selected"
task.wait(2)
local newMap = chosenMap:Clone()
newMap.Name = chosenMap.Name
newMap.Parent = workspace
local spawnPoints = newMap:FindFirstChild("SpawnPoints")
if not spawnPoints then
warn("Critical Error: There are no spawn points in "..chosenMap.Name.."!")
end
local availableSpawns = spawnPoints:GetChildren()
for i=5,0,-1 do
status.Value = "Game will start in "..i
task.wait(1)
end
remotes:WaitForChild("RoundMusic"):FireAllClients(chosenSong, "On")
for i, plr in pairs(plrs) do
if plr then
local character = plr.Character
coroutine.resume(coroutine.create(function()
if not character then
plr:LoadCharacter()
wait(0.1)
character = plr.Character
end
wait(1.2)
character.HumanoidRootPart.Position = availableSpawns[1].Position + Vector3.new(0, 8, 0)
local toolPack = replicatedStorage.MainGame.Tools.WeaponPacks:FindFirstChild(plr.EquippedPack.Value)
unpackageTools(plr, toolPack)
local gameTag = Instance.new("BoolValue")
gameTag.Name = "GameTag"
gameTag.Parent = character
end));
else
if not plr then
table.remove(plrs,i)
end
end
end
wait(1.3)
for i=gameLength,0,-1 do
for x, player in pairs(plrs) do
if player then
local character = player.Character
if not character then
table.remove(plrs,x)
else
if character:FindFirstChild("GameTag") then
--Still in game
continue
else
table.remove(plrs,x)
if player.leaderstats.Level.Value ~= 0 then
player.leaderstats.Cash.Value += (cashReward + math.floor(cashReward * player.leaderstats.Level.Value / 10) * player.Multiplier.Value)
player.leaderstats.Level.CurrentExp.Value += (expReward + math.floor(cashReward * player.leaderstats.Level.Value / 10) * player.Multiplier.Value)
else
player.leaderstats.Cash.Value += (5 * player.Multiplier.Value)
player.leaderstats.Level.CurrentExp.Value += (10 * player.Multiplier.Value)
end
player.leaderstats.Deaths.Value += 1
end
end
else
table.remove(plrs,x)
end
end
status.Value = "Time: "..toMS(i).." remaining"
if #plrs == 0 then
status.Value = "Restarting: No one survived."
break
elseif i == 0 then
status.Value = "Restarting: Time has run out."
for q, ply in pairs(plrs) do
if ply.leaderstats.Level.Value ~= 0 then
ply.leaderstats.Cash.Value += (cashReward + math.floor(cashReward * ply.leaderstats.Level.Value / 10) * ply.Multiplier.Value)
ply.leaderstats.Level.CurrentExp.Value += (expReward + math.floor(cashReward * ply.leaderstats.Level.Value / 10) * ply.Multiplier.Value)
else
ply.leaderstats.Cash.Value += (cashReward * ply.Multiplier.Value)
ply.leaderstats.Level.CurrentExp.Value += (expReward * ply.Multiplier.Value)
end
ply.leaderstats.Wins.Value += 1
end
break
end
wait(1)
end
wait(1.5)
for i, player in pairs(Players:GetPlayers()) do
local character = player.Character
if not character then
continue
else
if character:FindFirstChild("GameTag") then
character.GameTag:Destroy()
end
for _, tool in pairs(player.Backpack:GetChildren()) do
if tool:IsA("Tool") then
tool:Destroy()
end
end
for _, tool in pairs(character:GetChildren()) do
if tool:IsA("Tool") then
tool:Destroy()
end
end
end
player:LoadCharacter()
end
table.clear(plrs)
remotes:WaitForChild("RoundMusic"):FireAllClients(chosenSong, "Off")
status.Value = "Cleaning up map..."
wait(3)
newMap:Destroy()
wait(7)
end
return round
Any help is greatly appreciated!
Best regards,
Amora