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

Click to pick up tool?

I've been scripting for a year and i'm more into visuals and AI-Path finding but I'm making a game and I want to make a sword that just lays on the ground and you can click it and it adds to your inventory I can't think of a way to do it. I've looked it up all over and nobody really tells you how to do it, Yes I've seen the "Press "E" to pick up" I don't want that in my game pretty much my whole keyboard is taken up from movements, potions, light equipping and inventory / Crafting

2 answers

✓ Accepted answer

Simple answer. Whenever you create your tool, make sure that you create an brick to click first. Make the brick look precisely like the tool itself, by adding the mesh and giving it the correct dimensions. Place it down, and give it a click detector. Place your working tool in Lightning. Next, put a script inside of that brick that looks like the tool. Insert this code into the script:

Toolname = "Sword" -- Change "Sword" to your tool name.

-- Change "Sword" to your tool name.
function boop(Player)
	if not Player.Backpack:FindFirstChild("Sword") then
		local Tool = game.Lighting.Sword:Clone()
		Tool.Parent = Player.Backpack
	end
end
script.Parent.ClickDetector.MouseClick:connect(boop)

Finally, enter your game and click the brick. It should put the tool from inside Lightning into your backpack!

1 comment

0

thanks LoleyDude

Put a click detector in it and write the script from there maybe?

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