So I’ve made a combat system with knockback and I want the player to get stuck in a wall for 5 seconds if the character hit a wall, but I don’t really know how I should go about that.
Server script:
HitBoxPart.Touched:Connect(function(h)
if h.Parent:FindFirstChild('Humanoid') and h.Parent.Name ~= plr.Name and Cooldown == false then
print("Touched")
-- // Hit Confirmation & Hit Information Processing
game.ReplicatedStorage.remotes.HitConfirmation:FireClient(plr,HitStatus)
Cooldown = true
-- // Combat Effects
local ehrp = h.Parent:FindFirstChild("HumanoidRootPart")
local shockX = math.random(-180,180)
local Shock = PunchShock:Clone()
local SShock = SuperShockwave:Clone()
SShock.CFrame = CFrame.new((Char.HumanoidRootPart.CFrame * CFrame.new(0, 0, 0)).Position, Mouse.Position) * CFrame.Angles(0, math.rad(217), 90)
SShock.Parent = workspace
Shock.CFrame = ehrp.CFrame * CFrame.Angles(0,shockX,0)
Shock.Parent = workspace
spawn(function()
for i = 1,50 do wait()
Shock.Size = Shock.Size + Vector3.new(1.5,1.5,1.5)
Shock.Transparency = Shock.Transparency + 0.05
SShock.Size = SShock.Size + Vector3.new(1,4,1)
SShock.Transparency = SShock.Transparency + 0.05
end
end)
Derbis:AddItem(Shock,0.6)
Derbis:AddItem(SShock,0.6)
local HitBV = Instance.new("BodyVelocity")
HitBV.MaxForce = Vector3.new(math.huge, math.huge, math.huge)
HitBV.P = 100
HitBV.Velocity = Char.HumanoidRootPart.CFrame.lookVector*45
HitBV.Parent = ehrp
Derbis:AddItem(HitBV,1)
if not h.Parent:FindFirstChild("Humanoid") then
return
end
local Enemy = h.Parent.Humanoid
Enemy:TakeDamage(3)
spawn(function()
Enemy.WalkSpeed = 0
wait(0.1)
Enemy.WalkSpeed = 16
end)
wait(1)
Cooldown = false
end
end)