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

[SOLVED] Why does this method work fine with the same setup but different system?

I just solved this issue myself, no need to answer it.

Grammar note: I would've tabbed my paragraphs, but then ScriptingHelpers shows it as a code block

So, a few months ago I made a gun system so I could make FE guns and sell them, like usual. Then I decided to make a dedicated gun system for my dev team. It's the same exact setup for all the welds and everything, just how the system reads animation data. That's the only difference. Yet, for some reason, it acts in an entirely different way.

The method is simply something that changes a tool's grip from the right hand to the left hand, that way you can move the right hand freely without moving the tool, but when you move the left hand, the tool moves.

TL;DR: A method I made that switches which hand you hold the gun with is going insane

Here's the method in action (Focus on the part of the reload animation where he chambers the rifle)

Here's the method in complete insanity

Here's the code snippet in BOTH SYSTEMS

local LeftGrip = false

function SwitchHands()
	local Grip = RArm:FindFirstChild("RightGrip")
	if LeftGrip == false then
		Grip.Part1 = nil
		LeftGrip = Weld(LArm, Handle)
	else
		LeftGrip:Destroy()
		LeftGrip = false
		Grip.Part1 = Handle
	end
end

What the heck is going on here? I'm so confused!

2 answers

To me it looks that the fault is in the way how the animation has been made. In first one it works fine, because the gun gets attached back to left hand as the right hand does the cocking. In the other case, it defaults back to the right hand, but at the moment when it's doing the most intense animation it has.

I'd just suggest welding the gun to head instead, less of the hassle for you and the animator. Then both arms can move independently and you can control gun's position independently as well.

2 comments

0

My problem with this is, I'm moving the gun with the left hand, that and if you sprint while reloading, the gun will float there while the arms reload and go into sprint position

1

Perhaps consider animating based on dynamic positions. So that arm would always reach for certain part on a gun, instead of a hardcoded offset from torso or sort of like that.

I've figured out the answer to my own problem.

In my gun system is FPS Arms, in the second system, it waits for the server to spawn the main animation arms before the client spawns the FPS Arms. Problem with this is when you equip the gun and the FPS Arms are created, there are now two RightGrips, one in the character, and one in the FPS Arms. I simply added FakeRArm:ClearAllChildren() and now the system works perfectly!

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