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

2 comments
How do i use it, are there any example region3 script?
You may find it here https://developer.roblox.com/api-reference/function/Workspace/FindPartsInRegion3 !