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

How to add knockback for a gun? [closed]

Asked by
Th3_ViR0s -15
4 years ago
Edited 4 years ago

So I need some help to make a gun that when you fire, it pushes you back or up a little.

0
Request. Dovydas1118 1495 — 4y

Closed as Not Constructive by Dovydas1118 and JesseSong

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?

1 answer

Log in to vote
0
Answered by
Th3_ViR0s -15
4 years ago

I got it by detecting if you could see the gun part. Here is the code if anyone wants it!

script.Parent.Activated:Connect(function() local Camera = workspace.Camera local part = workspace.Gunn local _, withinScreenBounds = Camera:WorldToScreenPoint(part.Position)

if withinScreenBounds then
    local move = Instance.new("BodyVelocity")
    move.Parent = script.Parent.Parent.HumanoidRootPart
    move.Name = "Knockback"
    move.Velocity = Vector3.new(0,50,0)
    wait(0.5)
    move:Destroy()
end

end)

0
Did that work? If so, mark it as solved. Else, let this post be continued. 2Loos 168 — 4y
Ad