#Recoil effect doesnt do anything

48 messages · Page 1 of 1 (latest)

rain dirge
#

Im using a tween effect to create a recoil for my gun script and the output says that its working but no matter how I tweak the values it never actually does anything.

``local function ApplyRecoil()

local tweenInfo = TweenInfo.new(
    recoilDuration,  -- Duration
    Enum.EasingStyle.Sine, -- EasingStyle
    Enum.EasingDirection.InOut, -- EasingDirection
    0, -- Times to repeat
    true, -- Reverses
    0 -- Delay
)

local originalCFrame = handle.CFrame
local recoilCFrame = originalCFrame * CFrame.Angles(math.rad(-recoilAmount), 0, 0)

print("Applying recoil: Original CFrame: ", originalCFrame, " Recoil CFrame: ", recoilCFrame)

local recoilTween = tweenService:Create(handle, tweenInfo, {CFrame = recoilCFrame})
recoilTween:Play()

recoilTween.Completed:Connect(function()
    print("Recoil completed, returning to original CFrame")
    local returnTween = tweenService:Create(handle, tweenInfo, {CFrame = originalCFrame})
    returnTween:Play()
end)

end

--stuff

tool.Activated:Connect(function()
if not enabled then return end

enabled = false
fire:FireServer(mouse.Hit)
ApplyRecoil() -- Apply recoil effect
wait(fireRate.Value)
enabled = true

end)``

#

client is the recoil script

#

i have all the service fetching and variables outside the snippet i posted

#

chatgpt cant help so im coming here

solid iron
#

When you print the recoil cframe, does it output the expected result?

#

@rain dirge

rain dirge
#

the original and recoiled cframe are different but i’d have to check more in depth when i get home

#

works if i change the orientation directly instead ofof cframe but its not what i want

solid iron
#

So we know if it's the math or tween

#

It seems to check out tho

rain dirge
#

Applying recoil: Original CFrame: 309.548676, 6.52930641, 127.884804, -0.207814693, -0.0170843098, 0.978018999, -0.0618320592, 0.998077273, 0.00429629022, -0.976212084, -0.0595801026, -0.208471462 Recoil CFrame: 309.548676, 6.52930641, 127.884804, -0.207814693, 0.924880445, -0.318448126, -0.0618320592, -0.337325245, -0.939355314, -0.976212084, -0.175521508, 0.127288401

#

not sure what to make of this

solid iron
#

O whoops

#

That's some Einstein stuff

#

Or euler

#

Wtvr

rain dirge
#

looks like the last 3 numbers are different

solid iron
#

Do u know what a rotational matrix is

rain dirge
#

nope

solid iron
#

Me neither :|

rain dirge
#

nice

solid iron
#

But that's what it's printing

#

Try printing the recoil cframe orientation

#

Instead of the entire cframe

rain dirge
#

got it

solid iron
#

got what

#

The print?

rain dirge
#

the recoilcframe and original xyz are the same

#

Applying recoil: Original CFrame X: 313.67230224609375 Recoil CFrame X: 313.67230224609375 - Client - Client:78 21:13:05.859 Applying recoil: Original CFrame Y: 6.0517730712890625 Recoil CFrame Y: 6.0517730712890625 - Client - Client:79 21:13:05.859 Applying recoil: Original CFrame Z: 132.1536865234375 Recoil CFrame Z: 132.1536865234375

solid iron
#

That's weird

#

Try using fromEulerAngles

#

This is interesting

rain dirge
#

alright give me some time i’m busy but i’ll see what happens

solid iron
#

alr

#

Reddit post 💀

#

That might be doing something

rain dirge
#

i got no idea what that means

#

idk how to script so chatgpt does it for me

solid iron
#

Don't use chatgpt

#

Switch the two arpund

#

Instead of pos * angles do angles * pos

rain dirge
#

ima try using an animatoin it might yield better results

solid iron
#

Yeah but I'm still confused on why this doesn't work

solid iron
rain dirge
#

i got it to work with animatoins

#

thanks for the help though

solid iron
#

ok