It's a pet tool. It gives me an error: Attempt to connect failed: Passed value is not a function

local Tool = script.Parent local FluffyHandle = Tool.Handle

local FluffyInstance = nil

local Character = nil

--Destroy Fluffy.
function DestroyFluffy() if not FluffyInstance then return end FluffyInstance:Destroy() FluffyInstance = nil FluffyHandle.Transparency = 0

end

--Create a new Fluffy function CreateFluffy() if FluffyInstance then return end

	--Create a new Part for Fluffy
	FluffyInstance = FluffyHandle:Clone()
	FluffyInstance.Parent = Character.Head
	FluffyInstance.Anchored = true
	FluffyInstance.Name = "Fluffy"

	--Display Fluffy's sparkles
	local FluffySparkles = Instance.new("PointLight")
	FluffySparkles.Parent = FluffyInstance
	FluffySparkles.Color = Color3.new(255,255,255)
	FluffySparkles.Name = "FluffyTrail"
	FluffySparkles.Enabled = false
	FluffySparkles.Range = 8
	FluffySparkles.Brightness = 5
	--Tell Fluffy to orbit
	local FluffyAI = FluffyHandle.Parent.FluffyAIControl:Clone()
	FluffyAI.Parent = FluffyInstance
	
	FluffyHandle.Transparency = 1.0

end

function onActivated()

	if(Character == nil) then 
		print("Character Nil!")
		return 
	end
	if Tool.Enabled == false then 
		print("Tool Not Ready!")
		return 
	end
		
	
	if FluffyInstance then 
		DestroyFluffy()
		return 
	end
	
	Tool.Enabled = false
	
	CreateFluffy()

	Tool.Enabled = true

end

function onEquipped() Character = Tool.Parent Tool.Enabled = true Character.Humanoid.Died:connect(onControllerDied) end

function onUnequipped() Tool.Enabled = false Character.Humanoid.Died:connect(nil) Character = nil

end

function onControllerDied() DestroyFluffy()

end

Tool.Activated:connect(onActivated) Tool.Equipped:connect(onEquipped) Tool.Unequipped:connect(onUnequipped)

2 comments

0

Not sure why it split the code, all that code is 1 script.

0

Can you repost the code so it's all together? Also, what line is the error coming from?