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

Script is unable to index a boolean value?

So, I have a melee weapon, but whenever I click with it, I get the following error.

16:46:12.353 - Players.Player1.Backpack.Pipe.Script:28: attempt to index upvalue 'enabled' (a boolean value)

Here's my script.

local Tool = script.Parent
local hold = Instance.new("Animation")
hold.AnimationId = "http://www.roblox.com/Asset?ID=868783202"
local pipe = Instance.new("Animation")
pipe.AnimationId = "http://www.roblox.com/Asset?ID=868799736"
local animTrack = nil
local character = Tool.Parent.Parent.Character
local Humanoid = character.Humanoid
local enabled = script.Parent.Enabled

Tool.Equipped:connect(function(mouse)
	local ActiveTracks = Humanoid:GetPlayingAnimationTracks()	
	for _,v in pairs(ActiveTracks) do
  	 	v:Stop()
	end
	animTrack = character.Humanoid:LoadAnimation(hold)
	animTrack:Play()
end)

Tool.Unequipped:connect(function()
	local ActiveTracks = Humanoid:GetPlayingAnimationTracks()    
	for _,v in pairs(ActiveTracks) do
  	 	v:Stop()
	end
end)

function onActivation()
	if enabled.Value == true then
		enabled.Value = false
		local ActiveTracks = Humanoid:GetPlayingAnimationTracks()    
		for _,v in pairs(ActiveTracks) do
  		 	v:Stop()
		end
		animTrack = character.Humanoid:LoadAnimation(pipe)
		animTrack:Play()
		wait(0.55)
		local ActiveTracks = Humanoid:GetPlayingAnimationTracks()    
		for _,v in pairs(ActiveTracks) do
  		 	v:Stop()
		end
		animTrack = character.Humanoid:LoadAnimation(hold)
		animTrack:Play()
		enabled.Value = true
	end
end
 
Tool.Activated:connect(onActivation)

1 answer

an 'upvalue' is an external local variable. This error often occurs when a variable has been declared local in a forward declaration and then declared local again when it is initialized.

In your script you declare

local ActiveTracks = Humanoid:GetPlayingAnimationTracks() 

multiple times.

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