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

Why is my onTouch to give woodensword script not working?

Asked by 5 years ago

ok so i made this gear named "woodensword" --with all the animation done and all that, basically a sword that can swing and do damage. i wanted to make a script that gives the player the woodensword when they touch a part named "fire1".

function onTouch(fire1) local Toucher = fire1.Parent:FindFirstChild("Humanoid") --The toucher if Toucher ~= nil then --if someone touched fire1 local gear = game.ServerStorage.woodensword gear:Clone().Parent = Toucher:FindFirstChild("Backpack")

     end

end --yea so basically when you touch the part(fire1), you will get that woodensword

however, i have no idea why it is not working.

2 answers

Log in to vote
0
Answered by 5 years ago
gear:Clone().Parent = Toucher:FindFirstChild("Backpack")

Backpack is not a member of the Character's Humanoid. It will parent it to nil.

Ad
Log in to vote
0
Answered by 3 years ago
Edited 3 years ago

Part 1:

  -- // Variables                                           
local Tool = game.ServerStorage.woodensword
local Giver = script.Parent -- // The Part That Will Be Clicked
local New = Tool:Clone

-- // Getting The Click Detector To Work
Giver.ClickerDetector.MouseClick:Connect(function(player)

-- // If The Player Doesnt Already Have The Part Then
-- // When The 'Giver' Is Clicked The Player Will Be Recived With The Tool.
if New.Parent ~= player.Backpack then
New.Parent = player.Backpack
0
Click Here For The Instructions:                                                                                                            https://pastebin.com/MJz80Mwt  25MouseSensitivity 63 — 3y

Answer this question