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

How do I make it where when you touch a brick it gives a sword?

I need help making a script that gives a sword when you touch a brick.

6 answers

Here's what I think: First of all put a sword in the lighting and name it "Sword" then make a part in the Workspace and put this script in it:

script.Parent.Touched:connect(function(hit)
local find = hit.Parent:FindFirstChild("Humanoid")
if find then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local findS  = player.Backpack:FindFirstChild("Sword")
if not findS then
local sword = game.Lighting.Sword:Clone()
sword.Parent = player.Backpack
end
end
if not find then
print('no humanoid')
end
end)

(put inside the brick to be hit)

Incase you are still wondering;

local spam_prevention = false
script.Parent.Touched:connect(function(hit)
	print("Reaper5 was here")
IsPlayer = hit.Parent.Parent:FindFirstChild("Humanoid")
if IsPlayer ~= nil then
	if spam_prevention == false then spam_prevention = true end

Tool_To_Give = game.Lighting.Sword:Clone() --Change "Sword" to what tool you want to be given
player_ = game.Players[hit.Parent.Parent.Name]

Tool_To_Give.Parent=player_.Backpack
wait(1)
spam_prevention=false
end
end)

There are 2 ways you can do this, Insert a brick and name it Handle. (Do not do this if there is a part already in the tool) ~ OR ~ Create a brick then insert your tool in the brick. If there is already a brick in the tool it will be visible so hide somewhere that no one can see. (This will NOT affect the tool's handle position. It will attach to the character's arm.

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