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

Equipping a NPC with tool? - Easy Question! - Will Upvote!

Asked by 7 years ago

Hi, so I just started Lua Programming around for 2 weeks and so far I have found it so far, quite confusing. Please take a look at the code block before

wait(10)
local Weapon = game.ReplicatedStorage:GetChildren("Sword")
local Human = script.Parent -- "Human" is the NPC where all the parts are stored
Weapon:Clone().Parent = Human
Human:EquipTool(Weapon)

The purpose of this script is to clone the weapon into the NPC and make him equip it. The output says the error occurs at line 4 in which "Clone()" returns a nil value - I can't quite make out why.

In any case if you can tell me the answer to the code, then I would appreciate it.

Also, please note that I am a beginner so an explanation on each line of code would help a lot - I'm here to learn how to code not to copy other's code.

Answer this question