I'm trying to make a tool that drops a boulder upon clicking, and I keep getting an error message from my leader board saying "attempt to index local "killer" (a nil value) ".
--function that inserts that boulder/creator tag
local tool = script.Parent
local boulder = script.BScript
local clickEvent = tool.ClickEvent
local clickEventConnection
local bCreator = tool.Parent.Parent.Name
local function createPart(location)
local part = Instance.new("Part", game.Workspace)
part.Name = "Boulder"
part.Shape = "Ball"
part.Size = Vector3.new(13,13,13)
local mesh = Instance.new("FileMesh", part)
mesh.MeshId = "http://www.roblox.com/asset/?id=1290033"
mesh.TextureId = "http://www.roblox.com/asset/?id=1290030"
mesh.Scale = Vector3.new(10, 10, 10)
local bscript = boulder:Clone()
bscript.Parent = part
bscript.Disabled = false
local creatorTag = Instance.new('ObjectValue', part)
creatorTag.Value = bCreator
creatorTag.Name = 'creator'
part.CFrame = location
end
--Script that gets duplicated into the boulder
local boulder = script.Parent
local creatorTag = boulder:WaitForChild("creator")
local DebrisService = Game:GetService('Debris')
local function ApplyTags(target)
while target:FindFirstChild('creator') do
target.creator:Destroy()
end
local creatorTagClone = creatorTag:Clone()
DebrisService:AddItem(creatorTagClone, 1.5)
creatorTagClone.Parent = target
end
function onTouch(hit)
local humanoid = hit.Parent:findFirstChild("Humanoid")
if humanoid ~= nil then
if hit.Parent:findFirstChild("Boulder Shield")== nil then
humanoid.Health = humanoid.Health - 70
ApplyTags(humanoid)
end
end
end
script.Parent.Touched:connect(onTouch)
wait(5)
script.Parent:Destroy()

3 comments
Also, don't name anything "bCreator". That could be read as "a boolean value called creator". Same goes for "iCreator" (integer called creator), "fCreator" (float called creator), etc. Basically, avoid starting with a single lowercase letter.
For more info: https://en.wikipedia.org/wiki/Hungarian_notation
Thanks for the tip! I'll fix that.