Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

why is the tool not being given to the player?

I'm trying to make it so all tools the player has are taken from the player and they are given the clone of the tool I want to give them, except it isn't giving them the tool.

local tool = game.ServerStorage.Tools["Spool"]

script.Parent.Triggered:Connect(function(player)
	
	local t = tool:Clone()
	local hum = player.Character:FindFirstChild("Humanoid")
	player:WaitForChild("Backpack"):ClearAllChildren()
	wait(0.5)
	hum:EquipTool(t)
	
end)

1 answer

Its pretty easy, you've just forgot to parent the tool/weapon, I've also decided to put the code where all the Inventory you've have disappears before you get the weapon, this Is so the code doesn't get confused and deletes It, Hopes It helps

EDIT: I forgot to add that I've expect this Is a server script Inside of a Promp

local tool = game.ServerStorage.Tools["ClassicSword"] --Expects the tool Is Inside of a folder In ServerStorage

script.Parent.Triggered:Connect(function(player)
	
	player:WaitForChild("Backpack"):ClearAllChildren()  --Do this command before the user gets the weapon
	local t = tool:Clone()
	local Char = player.Character
	local hum = Char:FindFirstChild("Humanoid")
	t.Parent = Char --You've forget to parent the tool to the players Inventory
	wait(0.5)
	hum:EquipTool(t)

end)

This discussion is preserved as it was. New answers, comments, and votes are closed.