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

Attempt to call a nil value?

Help, I was trying to make a spreading fire script but I got this error instead. Attempt to call a nil value? I don't even know what that means? Help would be appreciated.

local childs = script.Parent:GetChildren()

function onTouched(hit)
	childs:Clone()
	childs.Parent = hit
end

script.Parent:connect(onTouched())

1 answer

✓ Accepted answer

When you do :GetChildren() it returns a table of all the Instances that are children of the object.

When you try to run Clone, it's not referencing an Instance, it's referencing the table, which does not have a function Clone inside it, therefore Clone is nil.

To fix this you can do

for i,v in pairs(childs) do
	local clone = v:Clone()
	clone.Parent = hit
end

1 comment

0

I get error Cannot change Parent of type TouchTransmitter

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