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

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

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

1 comment

0

Illegal question. Must be moderated.

1 answer

✓ Accepted answer

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.

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