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

Clicking the Button dis-equips you wepon?

i want it so when you click the button it dis-equips you wepon.

2 answers

You can unequip the player's tool by parenting it back from their character to their backpack, like so:

local plr = game:GetService("Players").LocalPlayer
button.MouseButton1Click:Connect(function()
	for i,v in pairs(plr.Character:GetChildren()) do
		if v.ClassName == "Tool" then
			v.Parent = plr:FindFirstChildOfClass("Backpack") or plr:WaitForChild("Backpack")
		end
	end
end)

1 comment

0

You know.. roblox made something called humanoid:UnequipTools()...

You can use the :UnequipTools() method on the Humanoid of the player's character to achieve this.

-- in a LocalScript
-- local button = workspace.Button
local plr = game:GetService("Players").LocalPlayer

button.MouseButton1Click:Connect(function() -- when dey clik it
	plr.Character.Humanoid:UnequipTools() -- poof no moar toolz
end

3 comments

0

workspace.Button? wat :thinking:

0

just an example

0

of what the "button" variable might be

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