#can someone help me in my fighting game (its very important)
4 messages · Page 1 of 1 (latest)
local HitboxEvent = ReplicatedStorage:WaitForChild("HitboxEvent")
local Players = game:GetService("Players")
HitboxEvent.OnServerEvent:Connect(function(attacker)
local attackerCharacter = attacker.Character
if not attackerCharacter then
warn("Attacker's character not found")
return
end
local humanoidRootPart = attackerCharacter:WaitForChild("HumanoidRootPart")
local hitbox = Instance.new("Part")
hitbox.Size = Vector3.new(5, 5, 5)
hitbox.Transparency = 0.5
hitbox.Color = Color3.new(1, 0, 0)
hitbox.Anchored = true
hitbox.CanCollide = false
hitbox.Parent = game.Workspace
hitbox.Position = humanoidRootPart.Position + humanoidRootPart.CFrame.lookVector * 2
spawn(function()
wait(0.12) -- Adjust delay if needed
hitbox:Destroy()
end)
local debounce = true
hitbox.Touched:Connect(function(hit)
if debounce then
local hitPlayer = Players:GetPlayerFromCharacter(hit.Parent)
if hitPlayer and hitPlayer ~= attacker then
local humanoid = hit.Parent:FindFirstChildOfClass("Humanoid")
if humanoid then
humanoid:TakeDamage(5)
end
end
debounce = false
end
end)
end)
this is the code
someone help me