Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Click to pick up tool?

Asked by 7 years ago

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

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

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!

0
thanks LoleyDude Tsb102403 -9 — 7y
Ad
Log in to vote
0
Answered by
PolyyDev 214 Moderation Voter
7 years ago

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

Answer this question