Hi, I’m making a punch script using region3 but when you click to punch, region3 only appears for a split second and then disappears. How can I make the region3 be there for the entire duration of the punching animation?
local Enabled = true
local Combo = 1
wait(.001)
script.Parent.OnServerEvent:connect(function(Player, Action)
local c = Player.Character
if Enabled == false then return end
if Action == "Combat" then
Enabled = false
if Combo == 1 then
Combo = 2
local Anim1 = c.Humanoid:LoadAnimation(script.Punch1)
Anim1:Play()
script.Event:Fire()
elseif Combo == 2 then
Combo = 1
local Anim2 = c.Humanoid:LoadAnimation(script.Punch2)
Anim2:Play()
script.Event:Fire()
end
wait(.2)
local Region = Region3.new(c.HumanoidRootPart.CFrame*CFrame.new(0,0,-2).p - Vector3.new(2,2,2),c.HumanoidRootPart.CFrame*CFrame.new(0,0,-2).p + Vector3.new(2,2,2))
local RTable = workspace:FindPartsInRegion3(Region, nil, 20)
for i,v in pairs(RTable) do
if v.Parent:findFirstChild("Humanoid") and v.Parent:findFirstChild("Deb") == nil and v.Parent ~= c then
v.Parent.Humanoid:TakeDamage(4)
local Deb = Instance.new("BoolValue", v.Parent)
Deb.Name = "Deb"
game.Debris:AddItem(Deb,0.2)
local S = Instance.new("Sound", v)
S.SoundId = "rbxassetid://131237241"
S.PlaybackSpeed = math.random(80,120)/100
S:Play()
local FX = Instance.new("Part", workspace.FX)
FX.Name = "CombatHit"
FX.Transparency = 0
FX.CanCollide = false
FX.Anchored = true
FX.Material = "ForceField"
FX.Color = Color3.new(1,0,0)
FX.Size = Vector3.new(1,1,1)
local SM = Instance.new("SpecialMesh", FX)SM.MeshType = "Sphere"
SM.Scale = Vector3.new(0,0,0)
FX.CFrame = v.Parent.HumanoidRootPart.CFrame*CFrame.new(math.random(-20,20)/10,math.random(-20,20)/10,math.random(-20,20)/10)
local BV = Instance.new("BodyVelocity", v)
BV.maxForce = Vector3.new(25000,25000,25000)
BV.Velocity = c.HumanoidRootPart.CFrame.lookVector*5
game.Debris:AddItem(BV,0.2)
end
end
wait(0.15)
Enabled = true
if script.Parent.Parent.Parent.Humanoid.Health < 1 then
script.Parent.Parent:Destroy()
end
end
end)
