Hi, I’ve been trying to make a sort of dash which has a hitbox that follows the player,. What would be the best method to make the hitbox stay in front of the player? Ive tried using part.Position = hrp.CFrame.Position but it didnt work.
game.ReplicatedStorage:WaitForChild(“dash”).OnServerEvent:Connect(function(plr)
local char = plr.Character
local hum = char:WaitForChild("Humanoid")
local hrp = char:WaitForChild("HumanoidRootPart")
local lv = Instance.new("LinearVelocity")
local attachment = hrp:WaitForChild("RootAttachment")
local animation = Instance.new("Animation")
animation.AnimationId ="http://www.roblox.com/asset/?id=id"
local animTrack = hum:LoadAnimation(animation)
animTrack:Play()
animTrack:GetMarkerReachedSignal("Dash"):Connect(function()
local size = Vector3.new(7, 10, 8)
local part = Instance.new("Part")
local cf = hrp.CFrame * CFrame.new(0, 0, ((part.Size.Z/2) + 0.5)* -1)
part.Position = hrp.CFrame.LookVector * 5
part.Massless = true
part.Transparency = 0
part.Anchored = false
part.CanCollide = false
part.CanQuery = false
part.CanTouch = false
part.CFrame = cf
part.Size = size
part.Parent = workspace
part.Anchored = true
local params = OverlapParams.new()
params.FilterType = Enum.RaycastFilterType.Exclude
params.CollisionGroup = "Default"
params.MaxParts = 5
params.FilterDescendantsInstances = {part}
params:AddToFilter(char)
local parts = workspace:GetPartBoundsInBox(cf, size, params)
local hitcharacters = {}
for i, part in pairs(parts) do
if part.Parent:FindFirstChild("Humanoid") and not table.find(hitcharacters, part.Parent) then
part.Parent:FindFirstChild("Humanoid").Health = part.Parent:FindFirstChild("Humanoid").Health - 35
local ehrp = part.Parent:FindFirstChild("HumanoidRootPart")
local uhrp = hrp
local att = Instance.new("Attachment", ehrp)
local lv = Instance.new("LinearVelocity", ehrp)
lv.MaxForce = 9999999
lv.Attachment0 = att
lv.VectorVelocity = uhrp.CFrame.LookVector * 80
game.Debris:AddItem(att, 0.1)
table.insert(hitcharacters, part.Parent)
end
wait(0.1)
end
print(hitcharacters)
part.CFrame = hrp.CFrame
hitcharacters = {}
--params:AddToFilter(hitcharacters)
--print(params)
end)
end)