I try to solve the problem, and then I Play the game and check my Backpack in player.Backpack when the tool is Equipped, it’s gone from the backpack, when You Unequip the tool then it will back to the player backpack, and the script works smoothly.
Here is the script :
for _, player in pairs (game.Players:GetChildren()) do
local char = player.Character
char.HumanoidRootPart.CFrame = lobbySpawn.CFrame
if InRound.Value == false then
local redClone = player.Backpack:GetChildren() do
redClone.RedHyperLaser:Destroy()
end
else
local blueClone = player.Backpack:GetChildren() do
blueClone.BlueHyperLaser:Destroy()
When the tool is equipped, it’s actually parented to the Player’s Character
To fix your issue, just simply implement 2 checks:
for _, Player in pairs(game.Players:GetPlayers()) do
local Char = Player.Character
Char.HumanoidRootPart.CFrame = lobbySpawn.CFrame
if InRound.Value == false then
if Char:FindFirstChild("RedHyperLaser") then
Char.RedHyperLaser:Destroy()
elseif Player.Backpack:FindFirstChild("RedHyperLaser") then
Player.Backpack.RedHyperLaser:Destroy()
end
end
end
How do i Implement this script for 2 Tools ?
because I got 2 tools for each team.
Red team variable is = RedHyperLaser
Blue team variable is = BlueHyperLaser
if InRound.Value == false then
if char:FindFirstChild("RedHyperLaser") then
char.RedHyperLaser:Destroy()
elseif player.Backpack:FindFirstChild("RedHyperLaser") then
player.Backpack.RedHyperLaser:Destroy()
Couple ways, but I’d just go through the Player’s Backpack and check if the names are equal to that
For the character check, maybe you could implement it like this but I’m not exact:
for _, Player in pairs(game.Players:GetPlayers()) do
local Char = Player.Character
Char.HumanoidRootPart.CFrame = lobbySpawn.CFrame
if InRound.Value == false then
if Char:FindFirstChild("RedHyperLaser") or Char:FindFirstChild("BlueHyperLaser") then
Char.RedHyperLaser:Destroy() or Char.BlueHyperLaser:Destroy()
end
for _, Tool in pairs(Player.Backpack:GetChildren()) do
if Tool.Name == "RedHyperLaser" or Tool.Name == "BlueHyperLaser" then
Tool:Destroy()
end
end
end
end