Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

creator tag value is nil?

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

0

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.

0

Thanks for the tip! I'll fix that.

1 answer

✓ Accepted answer

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.

3 comments

0

How would I fix that?

0

Change line 6 to local bCreator = tool.Parent.Parent --Also, change the name. It is confusing.

0

Thanks, it works!

This discussion is preserved as it was. New answers, comments, and votes are closed.