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

How do I make a script when the person is punched the other person gets knocked back? [closed]

Asked by 5 years ago

cheetah ocelot sea lion lemur chipmunk sea lion polar bear guinea pig wombat chipmunk hedgehog koala ok bye now

0
can you please make an attempt beforehand, and not weirdly name mammals theking48989987 2147 — 5y
0
make an attempt first LoganboyInCO 150 — 5y

Closed as Not Constructive by DragonSkyye, WideSteal321, ihatecars100, and User#24403

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

2 answers

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

You cannot just say "cheetah ocelot sea lion lemur chipmunk sea lion polar bear guinea pig wombat chipmunk hedgehog koala ok bye now" please tell us an error, show us code or at least make an attempt your question will/may be moderated for this, please remember this for next time

P.S. Expect rapid loss of reputation if you continue that can lead to suspension.

see the Community Guidelines (Look for Website Guidelines no. 2)

Ad
Log in to vote
-1
Answered by
Despayr 505 Moderation Voter
5 years ago
Edited 5 years ago

You could use a BodyVelocity.

local Debris = game:GetService("Debris")
local Event = script.Parent.PunchEvent
local Sp = 25

Event.OnServerEvent:Connect(function(Player)

    local Character = Player.Character
    local HRP = Character:FindFirstChild("HumanoidRootPart")

    Character.RightHand.Touched:Connect(function(hit)

    if hit and hit.Parent then
        local Humanoid = hit.Parent:FindFirstChild("Humanoid")
        local EnemyRootPart = hit.Parent:FindFirstChild("HumanoidRootPart")
        local BodyVelocity = Instance.new("BodyVelocity")

        if Humanoid then
            Humanoid:TakeDamage(25)
            BodyVelocity.MaxForce = Vector3.new(25000, 25000, 25000)
            BodyVelocity.Velocity = (HRP.CFrame.lookVector * Sp)
            BodyVelocity.Parent = EnemyRootPart

            wait(.5)

            Debris:AddItem(BodyVelocity, .2)
            end
        end
    end)
end)
3
This is a bad answer for multiple reasons. One, it breaks the community guidelines by providing zero explanation. Two, there is no context and the script is not good. Three, the question is a request and should not be supported by spoonfeeding. User#25115 0 — 5y