What do these errors mean

so i have this module script that when you click is suppose to make you do an anim while there is a sound playing and this is what i came up with so far

local module = {}

local Damage = require(game.ServerScriptService.ServerModules.TagHumanoid)
local wait = task.wait
local nicky = false



function ActionCheck(Player,Character)
	if Player:FindFirstChild("Ragdoll") then

	else
		return
	end
	return true
end



module.Active = function(Player,Character)
	local Status = workspace.AliveData[Player.Name].Status
	local Check = ActionCheck(Status,Character)
	local Tool = Player.Backpack:FindFirstChild("Inferno March")
	if Check ~= true and nicky == false then
		if nicky == true then 
		Tool.Equipped:Connect(function() 
		local anim = Character.Humanoid:LoadAnimation(script.Parent.Anim)
		anim:Play()
		local song = script.Song:clone()
		song.Parent = Character.HumanoidRootPart
		song:Play()
		if Tool.UnEquipped:Connect(function() then
		local anim = Character.Humanoid:LoadAnimation(script.Parent.Anim)
		local song = script.Song:clone()
		song.Parent = Character.HumanoidRootPart	
	    song:Stop()
	    anim:Stop()
		end)
	end)
end

return module;

but i am getting these errors
image
image
image

1 Like

It is due to this part. Why are you trying to connect a function in an if statement lol?

image

You’re getting the error because you have a syntax error in your code. You cannot connect an event handler while inside a if/then/else block. Remove the if/then or remove the Tool.Unequipped:Connect. You also have a capitalization error. It’s not UnEquipped, it’s Unequipped.

1 Like

i thought i needed too for the script to be able to determine that if it is unequipped run the set line of code

oh yeah thanks for pointing that out

1 Like

Well, you CAN do the event connection inside an if/then/else block, but not the way you were doing it. You had the event connection inside the conditional predicate which is why the JIT threw the error. You can do this (pseudocode)

if someVariable == someValue then
	someInstance.someEvent:Connect(function()
		-- Do some event handling stuff
	end)
end

Hope that clears things up a bit.

No Problem.

1 Like