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

How to make weapon drop script work?

I want to this script to be able to let players drop their weapons on the floor when they die. I also Want it to say v to pick up weapon above that weapon when it was dropped.

This is the script I have so far.

Tool = script.Parent
Char = Tool.Parent.Parent.Character

function onDeath()

if Tool.Parent == Char then
Tool.Parent = game.Workspace
end
end

Char.Humanoid.Died:connect(onDeath)

1 comment

0

is it in a LocalScript or script?

1 answer

✓ Accepted answer

Instead of trying to do this from the tool's perspective.. why not just put a script in workspace that makes it so whenever the character dies they drop their tool?

I'm not going to help with the press 'v' to pickup part because that would be non constructive on your part if I just did it for you.

--Function to drop tools
function dropTools(char)
	for i,v in pairs(char:GetChildren()) do
		if v:IsA('Tool') then
			v.Parent = workspace
		end
	end
end

--Player joins
game.Players.PlayerAdded:connect(function(plr)
	--Character spawns
	plr.CharacterAdded:connect(function(char)
		--Connect died event
		local hum = char:WaitForChild('Humanoid')
		hum.Died:connect(function()
			dropTools(char)
		end)
	end)
end)

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