I am making a boss battle and I'm using pcall catch some of the errors. But when using it a function I made called sword strike always returns false, but there's no error message. Also this game is SINGLE

In module script

local BodyGyro = script.Parent.BodyGyro
local BodyPos = script.Parent.BodyPosition

function swordstrike(swordval,speed) --creates a sword 160 studs above the player
	for i = 1, swordval do
		BodyPos.position = Vector3.new(132.169, 5.2, 1333.305)
		local s = game.ReplicatedStorage.DuckySword:Clone()
		for _, Player in pairs(game.Players:GetPlayers()) do
			s.BodyPosition.Position = Player.Character.Torso.Position
			s.Position = Player.Character.Torso.Position + Vector3.new(0,160,0)
		end
		s.Parent = script.Parent.Parent
		game:GetService("Debris"):AddItem(s,2)

		wait(speed)
	end
end

return {--other stuff
,swordstrike = swordstrike}

In regular script

swordstrike = require(script.Parent.ModuleScript).swordstrike

for i =  1,5 do
	pccallerrror2, message = pcall(run)
		if pccallerrror2 then
			run(0.5,20)
		end
	end

5 comments

0

Is the function run defined anywhere? If so, can you post it?

0

and no

0

wait, pcalls have to be defined with a function........

0

And I did

0

Wait my bad I see your point