I'm new to programming, I just need a key to be issued when I press a button.
COMMUNITY QUESTION
How do I make a script that gives me a tool when I click on a part?
2 answers
Put the tool you want to be added inside replicated storage. Put a script inside the part. Also, put a click detector inside the part.
local part = script.Parent
local replicatedStorage = game:GetService("ReplicatedStorage")
part.MouseClick:Connect (function(player)
local tool = replicatedStorage.Tool:Clone() --Set this to the name of your tool.
tool.Parent = player.Backpack
I hope this helps.
My sincere apologies if this doesn't work.
Don't forget to accept this answer is this works!
1 comment
0
Dude, what are you doing? In arches should not be player but part
Players = game:GetService("Players") -- Service Players (need to get player from character)
part = game.Workspace.Part -- Your part
ClickDetector = part.ClickDetector -- Add ClickDetector to your part
Tool = game.ReplicatedStorage.Tool -- Your tool in ReplicatedStorage
Put your tool to ReplicatedStorage and add ClickDetector to your part
ClickDetector.MouseClick:Connect(function(click)
local character = click.Parent -- Character (we gets that for player that have backpack)
local player = Players:GetPlayerFromCharacter(character) -- player itself
local ClonedTool = Tool:Clone() -- You cloning your tool from RepStorage
ClonedTool.Parent = player.Backpack -- And after you putting your tool to player's Backpack
end)
Say if you have any errors. And you should remember, put your tool to ReplicatedStorage.
This discussion is preserved as it was. New answers, comments, and votes are closed.

1 comment
Please make an attempt before asking a question