Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Knockback not exactly working?

Asked by 2 years ago

hi, so basically i have a knockback system for a bat i made, but the knockback only seems to work for a split second, and even though ive tried like adding waits, it either does it at the very start, or just doesnt do it at all. Help would be appreciated

Here is the script that gets activated when a remote event is fired

01game.ReplicatedStorage.Bat.OnServerEvent:Connect(function(player)
02    local debounce = false
03    local char = player.Character or player.CharacterAdded:Wait()
04    local tool = char:FindFirstChild("Bat")
05    local bat = tool
06 
07    local RegionPos1 = bat.Handle.hitbox.Position - (bat.Handle.hitbox.Size / 2)
08    local RegionPos2 = bat.Handle.hitbox.Position + (bat.Handle.hitbox.Size / 2)
09    local HitboxRegion = Region3.new(RegionPos1, RegionPos2)
10 
11    task.wait(1)
12 
13    bat.Handle.SWING:Play()
14 
15 
View all 65 lines...

1 answer

Log in to vote
1
Answered by 2 years ago

I think I found your problem

I saw:

1HitTorso.Velocity

In your code and Velocity Is Deprecated meaning It will no longer work on new work

I decided to put this script Inside of a part which knockbacks players away from It:

01script.Parent.Touched:Connect(function(hit)
02    local humanoid = hit.Parent:FindFirstChild("Humanoid")
03    if humanoid then
04        if not humanoid.Parent.Torso:FindFirstChild("VectorForce") then
05            local VectorForce = Instance.new("VectorForce")
06            local Attachment = Instance.new("Attachment")
07 
08            VectorForce.Parent = humanoid.Parent.Torso
09            Attachment.Parent = humanoid.Parent.Torso
10            VectorForce.Force = Vector3.new(0,300,6000)
11            VectorForce.Attachment0 = Attachment
12            VectorForce.ApplyAtCenterOfMass = true
13            humanoid.Jump = true
14            game:GetService("Debris"):AddItem(VectorForce,0.5)
15            game:GetService("Debris"):AddItem(Attachment,0.5)
16        end
17    end
18end)
0
Thank you so much! it works! DriBowser 55 — 2y
0
You have no idea how long ive been looking for this, so thanks again! DriBowser 55 — 2y
0
No Problem! imnotaguest1121 362 — 2y
Ad

Answer this question