Issue
Hello! I made a script that adds and removes gears at the start/end of the round. From testing, I have found that the script does remove the gear in the player’s backpack but not the gear the player is holding. I have sourced the internet but haven’t found a solution.
Code
This part of the script removes the gears from the player’s backpack other than the one the player is using:
inRound.Changed:Connect(function()
if inRound.Value == false then
for i, plr in pairs(game.Players:GetPlayers()) do
local char = plr.Character
local humanRoot = char:WaitForChild("HumanoidRootPart")
plr.Backpack:ClearAllChildren()
humanRoot.CFrame = game.Workspace.lobbySpawn.CFrame
end
end
end)
Credit to mari230899 for the help on this script.
This script adds the gears, though I dont think you need to worry about this one.
game.Workspace.ChildAdded:Connect(function(child)
if child.Name == "Sword Fights on the Heights IV" then
local musicFolder = game.SoundService.Music
for _, v in pairs(musicFolder:GetChildren()) do
v:Stop() --stops all playing music
end
game.SoundService.Music.SFOTHTheme:Play()
for index, plr in pairs(game.Players:GetPlayers()) do
if plr:FindFirstChild("Backpack") then
-- Adds gear right here! (hey that rhymes :O)
local tool = game.ServerStorage.Tools.ClassicSword:Clone()
tool.Parent = plr.Backpack
end
end
local function skyChange()
SFOTHSky.Parent = Lighting
DefaultSky.Parent = Skyboxes
end
skyChange()
end
end)
Thanks for any help!