Hello! I am having a problem with my hitboxes. When the dummy is obviously touching the hitbox, the script doesn’t process it and no damage is done.
here is the local script:
wait(2)
local yevent = game.ReplicatedStorage.yujiEvent
local UIS = game:GetService("UserInputService")
local plr = game.Players.LocalPlayer
local p1 = script.p1
local p2 = script.p2
local p3 = script.p3
local isusingy = false
yevent.OnClientEvent:Connect(function()
local char = plr.Character
local p1l = char.Humanoid:LoadAnimation(p1)
local p2l = char.Humanoid:LoadAnimation(p2)
local p3l = char.Humanoid:LoadAnimation(p3)
local stunned = char:GetAttribute("Stunned")
local blocking = char:GetAttribute("Blocking")
local canp2 = false
local canp3 = false
local isusingy = true
UIS.InputBegan:Connect(function(input, gpc)
if gpc then return end
if input.UserInputType == Enum.UserInputType.MouseButton1 and canp2 == false and canp3 == false then
if stunned == true or blocking == true then return end
local hitbox = game.ReplicatedStorage.hitbox:Clone()
hitbox.Parent = workspace
hitbox.CFrame = char.HumanoidRootPart.CFrame + Vector3.new(0,0,-5) * char.HumanoidRootPart.CFrame.LookVector * -1
p1l:Play()
hitbox.TouchEnded:Connect(function(hit)
if hit.Parent.Humanoid then
if hit.Parent.Name ~= plr.Name then
print(hit.Name)
game.ReplicatedStorage.fightEvent:FireServer(isusingy, hit.Parent.Humanoid)
hitbox:Destroy()
end
end
end)
canp2 = true
wait(0.7)
hitbox:Destroy()
canp2 = false
elseif input.UserInputType == Enum.UserInputType.MouseButton1 and canp2 == true and canp3 == false then
local hitbox = game.ReplicatedStorage.hitbox:Clone()
hitbox.Parent = workspace
hitbox.CFrame = char.HumanoidRootPart.CFrame + Vector3.new(0,0,-5)* char.HumanoidRootPart.CFrame.LookVector * -1
p2l:Play()
hitbox.TouchEnded:Connect(function(hit)
if hit.Parent.Humanoid then
if hit.Parent.Name ~= plr.Name then
game.ReplicatedStorage.fightEvent:FireServer(isusingy, hit.Parent.Humanoid)
hitbox:Destroy()
end
end
end)
canp3 = true
wait(0.7)
hitbox:Destroy()
canp3 = false
elseif input.UserInputType == Enum.UserInputType.MouseButton1 and canp2 == false and canp3 == true then
local hitbox = game.ReplicatedStorage.hitbox:Clone()
hitbox.Parent = workspace
hitbox.CFrame = char.HumanoidRootPart.CFrame + Vector3.new(0,0,-5)* char.HumanoidRootPart.CFrame.LookVector * -1
p3l:Play()
hitbox.TouchEnded:Connect(function(hit)
if hit.Parent.Humanoid then
if hit.Parent.Name ~= plr.Name then
game.ReplicatedStorage.fightEvent:FireServer(isusingy, hit.Parent.Humanoid)
hitbox:Destroy()
end
end
end)
wait(0.2)
hitbox:Destroy()
end
end)
end)
Server Script:
local event = game.ReplicatedStorage.fightEvent
event.OnServerEvent:Connect(function(plr, isusingy, hum)
if isusingy == true then
hum:TakeDamage(5)
end
end)