Hi, beginner dev here. I am trying to make a script that should sort players into teams, place a tool into one team's inventory, and teleport the players to the map and lobby. The script works perfectly fine, except it won't put the tool into the player's inventory. There are no errors in the script or in output. I have tried dozens (not an exaggeration) of variations of the script but none of them work. I really need somebody to work with me here. Below is part of the script without any of the code that gives the tool to the team. I just need to know what to add to the script to transfer the tool, or if I need to change any other things to make it work.
InRound.Changed:Connect(function() if InRound.Value == true then local RandomPlayer = game.Players:GetPlayers()[math.random(1,PlayerCount)] RandomPlayer.Team = Killer for _, player in pairs(game.Teams.Lobby:GetPlayers()) do player.Team = Campers for _, player in pairs(game.Players:GetChildren()) do player:LoadCharacter() end end else for _, player in pairs(game.Players:GetChildren()) do player.Team = Lobby local char = player.character char.HumanoidRootPart.CFrame = Spawn.CFrame end end end)
local player = game.Players.LocalPlayer local tool = game.ServerStorage.Tool --Reference your tool here local toolclone = tool:Clone() --Clones the tool toolclone.Parent = player.Backpack
I hope this helps!
Seems like you have some player objects. Clone the tool and then: You have 3 options 1. Parent the tool to the Player.Backpack. 2. Parent the tool to the character (But you can do that only with 1 tool). 3. Get the humanoid and do Humanoid:EquipTool(toolObject). Way 1:
--Here's an example of way 1 local tool = nil --Replace nil with the path to your tool (e.g. ServerStorage.Sword) local clone = tool:Clone() clone.Parent = RandomPlayer --Seems like you already defined RandomPlayer so I used it.
Way 2:
--Here's an example of way 2 local tool = nil --Replace nil with the path to your tool (e.g. ServerStorage.Sword) local clone = tool:Clone() clone.Parent = (RandomPlayer.Character or RandomPlayer.CharacterAdded:Wait()) --Seems like you already defined RandomPlayer so I used it. --If you use this way, you can parent only one tool.
Way 3:
--Here's an example of way 3 local tool = nil --Replace nil with the path to your tool (e.g. ServerStorage.Sword) local clone = tool:Clone() local char = RandomPlayer.Character or RandomPlayer.CharacterAdded:Wait() --Seems like you already defined RandomPlayer so I used it. local humanoid = char:WaitForChild("Humanoid") humanoid:EquipTool(clone) --If you use this way, you can parent only one tool.
Note: None of these ways work with a local script. Use them in a local script since everyone should be aware of the tool being given to the player.