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

How to remove a tool when someone has it enabled?

I have this short script here that I want to use to remove a certain tool. But the problem is if the player has it enabled it won't be removed. Is there a way to access what they have selected?

Here's the script:

first_infected.StarterGear.Shrike:remove()
	first_infected.Backpack.Shrike:remove()

Thanks!

1 comment

0

I haven't tested it, but I edited my answer to include a different solution that may solve the problem?

2 answers

✓ Accepted answer

Tools, when equipped, are moved into the player's character.

Just check there, too (I'm unsure if deleting an equipped tool might have bad effects)

place = first_infected.StarterGear;
if place:FindFirstChild("Shrike") then
	place.Shrike:Destroy()
end
place = first_infected.Character;
if place:FindFirstChild("Shrike") then
	place.Shrike:Destroy()
end

This solution may fix the problem you saw:

place = first_infected.StarterGear;
if place:FindFirstChild("Shrike") then
	place.Shrike:Destroy()
end
place = first_infected.Character;
if place:FindFirstChild("Shrike") then
	local tool = place.Shrike;
	tool.Enabled = false;
	tool:Destroy()
end

5 comments

0

Thanks it worked. Unfortuantely it keeps my arms in the same position. To fix it is it like Cframing?

1

Unfortunately I'm not sure how to fix it. I believe if they equip another tool and de-equip that, it will be fixed, but I'm not sure the most elegant way to fix this.

0

Alright, thanks I'll play around with it. Appreciate the help :)

0

I'll try that but I I've started this below.

0

Mine worked. I'll edit mine to the full script

place = first_infected.Character;
		if place:FindFirstChild("Shrike") then
   	 place:FindFirstChild("Shrike").Parent = first_infected.Backpack
	wait()
	v.Backpack.Shrike:Destroy()
	end

It removes it to the backpack from where I can destroy it.

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