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()
No formatting is better than bad formatting. But good formatting (the type ROBLOX provides itself) is better than no formatting.
Include formatting.
Also, include the complete error message. Knowing the script and line number is nice.
Anyway, the issue looks like it originates in a different script (the one which created the tag in the first place). It looks to me like it creates the tag and puts it in the projectile, but does not set its value.
EDIT: According to the code which creates the original tag, you are assigning the ObjectValue's value (which is, well, an object) to the player's name (which is a string). This would produce an error.