Hello, for some reason my system does not work. Preferably on the part where it checks if its been touched.
The Code:
local ServerScriptService = game:GetService("ServerScriptService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local ServerCombat = ServerScriptService:FindFirstChild("Server Combat")
local Remote = ReplicatedStorage.Remotes
-- hitbox script
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(Character)
local Script = ReplicatedStorage.Storage["Combat Hitbox"].Hitbox["Main Script"]:Clone()
local Configs = ReplicatedStorage.Storage["Combat Hitbox"].Hitbox.Configuration:Clone()
local Hitbox = Instance.new("Part", plr.Character["HumanoidRootPart"])
local Weld = Instance.new("WeldConstraint", Hitbox)
Hitbox:PivotTo(plr.Character["HumanoidRootPart"].CFrame)
Weld.Part0 = Hitbox
Weld.Part1 = plr.Character["HumanoidRootPart"]
Hitbox.Massless = true
Hitbox.CanCollide = false
Hitbox.Transparency = 0.5
Hitbox.Size = Vector3.new(5,6,2.8)
Configs.Parent = Hitbox
Configs.Owner.Value = plr.Name
end)
end)
-- main script
Remote:WaitForChild("Hit").OnServerEvent:Connect(function(plr,input,Combo)
if input == "M1" then
if Combo == 1 then
print(Combo)
local Debounce = false
Debounce = false
local Hitbox = plr.Character.HumanoidRootPart.Part
local Animation = ServerCombat.Anims["punch #1"]
local AT = plr.Character.Humanoid:LoadAnimation(Animation)
AT:Play()
wait (0.1)
Hitbox.Touched:Connect(function(target)
if target.Parent.Name ~= plr.Name and Debounce == false then
Debounce = true
target.Humanoid.Health -= 5
end
end)
elseif Combo == 2 then
local Debounce = false
Debounce = false
local Hitbox = plr.Character.HumanoidRootPart.Part
local Animation = ServerCombat.Anims["punch #2"]
local AT = plr.Character.Humanoid:LoadAnimation(Animation)
AT:Play()
wait (0.1)
Hitbox.Touched:Connect(function(target)
if target.Parent.Name ~= plr.Name then
if Debounce == false then
Debounce = true
target.Humanoid.Health -= 5
end
end
end)
elseif Combo == 3 then
local Debounce = false
Debounce = false
local Hitbox = plr.Character.HumanoidRootPart.Part
local Animation = ServerCombat.Anims["punch #1"]
local AT = plr.Character.Humanoid:LoadAnimation(Animation)
AT:Play()
wait (0.1)
Hitbox.Touched:Connect(function(target)
print(target)
if target.Parent.Name ~= plr.Name then
if Debounce == false then
Debounce = true
target.Humanoid.Health -= 5
end
end
end)
end
end
end)
Have you tried debugging like printing target.Parent.Name? Now nothing against your methods of hitboxes, but .Touched is very outdated and you should probably resort to more reliable and precise methods. You didn’t mention specifically what was going wrong, but a video would be helpful as well.