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

Can you make me a script that if you clicked the part, it will give you a tool?

Asked by 3 years ago

Can you???????????????????????????????????????????????????????

0
Illegal question. Must be moderated. krowten024nabrU 463 — 3y

1 answer

Log in to vote
0
Answered by
Soban06 410 Moderation Voter
3 years ago

So here it goes:

First of all, insert a tool in workspace. Let's call the tool 'Sword' (You can call it anything you want). Insert a part inside that tool and call it 'Handle'. You can design your tool the way you want. Then move that tool inside 'replicated storage'. Now insert a part inside the workspace and insert a clickdetector and a script inside it (the part in the workspace). Inside the script, write this:

local Tool = game.ReplicatedStorage.Sword -- Sword is the name of the tool (name it whatever your tool's name is)
local clickDetector = script.Parent.ClickDetector

clickDetector.MouseClick:Connect(function(player)
    Tool:Clone().Parent = player.Backpack
end)

Now this will add the tool to your backpack when you click the part.

But there is a problem here. Whenever you click the part, it will keep adding the sword as long as you keep clicking it. This will spam your backpack. We don't want that. We only want the tool to be added once and then if you click the part again, you shouldn't get the tool because you already have it. So this is the total script:

local Tool = game.ReplicatedStorage.Sword -- Sword is the name of the tool (name it whatever your tool's name is)
local clickDetector = script.Parent.ClickDetector

clickDetector.MouseClick:Connect(function(player)
    if not player.Backpack:FindFirstChild("Sword") then
        Tool:Clone().Parent = player.Backpack
    end
end)

Hope this helped. If you have any questions regarding my answer, please comment.

Ad

Answer this question