You can write your topic however you want, but you need to answer these questions:
-
What do you want to achieve? Keep it simple and clear!
I would like to have my VR hand get sent back (or recoil) when I shoot a gun. -
What is the issue? Include screenshots / videos if possible!
I can’t figure out how to make it. -
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I’ve been told that the spring module is good for this kind of stuff, but I can’t figure out how to use it
In case you need it, this is my gun script:
local GunModule = {}
GunModule.Shoot = function(plr, hand)
local Settings = require(script.Parent.Settings)
local spring = require(script.Spring)
if script.Parent.Debounce.Value == false then
script.Parent.Debounce.Value = true
local rayOrigin = script.Parent.Parent.Barrel.ShootingPoint.WorldPosition
local rayDirection = script.Parent.Parent.Barrel.CFrame.LookVector * 1000
local shotsound = script.Parent.Shot
-- Build a "RaycastParams" object and cast the ray
local raycastParams = RaycastParams.new()
raycastParams.FilterDescendantsInstances = script.Parent.Parent:GetChildren()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
local raycast = workspace:Raycast(rayOrigin, rayDirection, raycastParams)
if raycast then
local hitPart = raycast.Instance
local directhit = raycast.Position
--bullet hole supposed to hapen good
local BulletHole = game.ReplicatedStorage.BulletHole:Clone()
BulletHole.Parent = game.Workspace
BulletHole.Position = directhit
local weld = Instance.new("WeldConstraint")
weld.Parent = BulletHole
weld.Name = "BulletHoleWeld"
weld.Part0 = hitPart
weld.Part1 = BulletHole
BulletHole.Script.Disabled = false
end
spring.new(65, 55, 25, 3.2, 1*Settings.RecoilMultiplier, 0)
shotsound.TimePosition = 0
shotsound.PlaybackSpeed = math.random(0.85, 1.15)
shotsound:Play()
script.Parent.Parent.MuzzleFlash.MuzzleEffect.Enabled = true
script.Parent.Parent.MuzzleFlash.SpotLight1.Enabled = true
script.Parent.Parent.MuzzleFlash.SpotLight2.Enabled = true
script.Parent.Parent.MuzzleFlash.SpotLight3.Enabled = true
wait(0.05)
script.Parent.Parent.MuzzleFlash.MuzzleEffect.Enabled = false
script.Parent.Parent.MuzzleFlash.SpotLight1.Enabled = false
script.Parent.Parent.MuzzleFlash.SpotLight2.Enabled = false
script.Parent.Parent.MuzzleFlash.SpotLight3.Enabled = false
wait(Settings.FireRate-0.05)
script.Parent.Debounce.Value = false
end
end
return GunModule