So hey I was wondering whether it was actually possible to make a gun which has a reach of 3 studs and could deal some knockback.
Not sure what you mean by this
And yes Dealing knockback is quite easy Use body movers I personally just add on to the velocity(deprecated Property of basepart)
I mean that the gun can only shoot 3 studs away…
Do you mean the gun is 3 studs in length, or do you really mean the projectile can only reach 3 studs, because that seems dumb, or what
projectile can only reach 3 studs
A ray or a moving projectile? you can* just experiment with BodyMover | Roblox Creator Documentation 's if you want a moving projectile
Roblox has a built-in feature called Magnitude, you can use it to get the distance between two objects.
-
You can first get the positions of your character and the object.
-
Then use magnitude to compare the distance between you and the object.
-
Lastly, do something like:
local magnitude = (Character.HumanoidRootPart.Position - ObjectHit.Position).magnitude
if magnitude < 4 then --// if the object is less than 3 studs away
-- Do stuff
else
-- Ignore object
end