Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

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

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

2 comments

0

can you please make an attempt beforehand, and not weirdly name mammals

0

make an attempt first

2 answers

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)

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)

1 comment

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.

This discussion is preserved as it was. New answers, comments, and votes are closed.