I need help making a script that gives a sword when you touch a brick.
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)
Here's my answer: What you're talking about is a giver. Here I have a link that'll get you started maybe without a script: http://www.roblox.com/Basic-Giver-item?id=3140741
(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.
Closed as Not Constructive by Articulating and evaera
This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.
Why was this question closed?