local blockevent = game:GetService("ReplicatedStorage").Events.Block
local player = game.Players.LocalPlayer
blockevent.OnServerEvent:Connect(function(player)
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = char:WaitForChild("Humanoid")
local rootpart = char:WaitForChild("HumanoidRootPart")
local hitbox = Instance.new("Part")
hitbox.Name = "BlockHitbox"
hitbox.Size = Vector3.new(2,3,1.4)
hitbox.Parent = rootpart
hitbox.CFrame = rootpart.CFrame + (rootpart.CFrame.lookVector * 2.1)
hitbox.CanCollide = false
hitbox.CanQuery = false
hitbox.Transparency = 0
humanoid.JumpPower = 0
local weld = Instance.new("WeldConstraint", hitbox)
weld.Part0 = hitbox
weld.Part1 = hitbox.Parent
end)
part of script where checking if hitbox of block touching:
for v, part in pairs(hit:GetChildren()) do
if v == "BlockHitbox" and part.Parent ~= "Hitbox" then
dashevent:FireClient(player, results)
return
end
end
i dont understand what i should do, the part of script where checking if hitbox of block touching dont work, no errors on output, but no checking (it still hitting person even if he block attack). maybe someone know how to do it better, or fix it?
Problem: It is not checked whether the hitbox touched a block with a regular hitbox.
Preferably, if there is another way to make it easier, and it will also use the block hitbox, tell me about it (because I want to repeat the block system as in the strongest battlegrounds).
for reference, in the strongest battlegrounds, if you pressed F (block), then you will block the attack if the enemy was in front, but if the enemy is behind, he will be able to hit you
for v, part in pairs(hit:GetTouchingParts()) do
if v == "BlockHitbox" and part.Parent ~= "Hitbox" then
dashevent:FireClient(player, results)
return
end
end
you were getting the children instead of the touching parts
local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local humanoid = script.Parent.Parent:WaitForChild("Humanoid")
local rootpart = script.Parent.Parent:WaitForChild("HumanoidRootPart")
local animationController = game:GetService("Players").LocalPlayer.Character:WaitForChild("Humanoid"):WaitForChild("Animator")
local UIS = game:GetService("UserInputService")
--block
local animation = Instance.new("Animation")
animation.AnimationId = "rbxassetid://15184008907" -- замените на свой AnimationId
local animationTrack = animationController:LoadAnimation(animation)
local blockevent = game:GetService("ReplicatedStorage").Events.Block
--clicks
local clickremote = game:GetService("ReplicatedStorage").Events.M1Event
local debounce = false
--end
UIS.InputBegan:Connect(function(key, typing)
if typing then return end
if key.KeyCode == Enum.KeyCode.F then
if humanoid.WalkSpeed ~= 0 then
animationTrack:Play()
blockevent:FireServer(player)
humanoid.WalkSpeed = 2
end
end
end)
for v, part in pairs(hit:GetChildren()) do
if v == "BlockHitbox" and part.Parent ~= "Hitbox" then
dashevent:FireClient(player, results)
return
end
end
what is results and what is hit, how can we help u if u give us magical variable, u could maybe show us the entire script and then we would be able to help u, else part.Parent ~= “Hitbox” will always be true cuz a instance cannot be a string
Hope it helped !
for v, part in pairs(hit:GetChildren()) do
if v == "BlockHitbox" and part.Parent ~= "Hitbox" then
dashevent:FireClient(player, results)
return
end
end
explaining: first stroke - we get whether the enemy has a BlockHitbox (hit == HumanoidRootPart), second stroke: we checking if v it’s a hit:GetChildren() == BlockHitbox, and checking if touching part is a Hitbox of dash ability. third stroke - fire a client with a results (if results is good - stop a dash).