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

How do i give all the monsters damage who is in the part?

This is the script, but there is one mistake. When i delete script.Parent.CanDamage thing, its giving all monsters damage but they are getting one hit. When i add it, then it just hitting one monster. How do i fix it?

local Attack = true


if Attack == true then

script.Parent.Activated:Connect(function()

local character = script.Parent.Parent
local Humanoid = character:WaitForChild('Humanoid')
local torso = character:WaitForChild('HumanoidRootPart')
	
local part = Instance.new("Part", game.Workspace)
	part.Size = Vector3.new(7.3, 4 ,3)
	part.CanCollide = false
	part.Transparency = 0.5
	part.CFrame = torso.CFrame+(torso.CFrame.lookVector*3)
	
part.Touched:Connect(function(p)
	if p.Parent.Name == ("Mob") then
		
		local hum = p.Parent:FindFirstChildOfClass("Humanoid")
		if script.Parent.CanDamage.Value == true then
			script.Parent.CanDamage.Value = false
			hum:TakeDamage(20)
			wait(0.5)
			script.Parent.CanDamage.Value = true
			
		end
		
		
	end
end)

end)

end

1 answer

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