I am trying to create a script where there is a LocalScript inside the player(s), which records if a player presses, and releases a certain key, which in this case, is Z. Pressing the key fires a remote and tells the remote they are holding the key with a boolean. Releasing the same key fires the same remote, but this time telling the remote they are not holding the key with the same boolean. So far I have created this script, but had a lot of changes to it, and decided to rewrite the entire remoteevent function according to the help I have received from the people on this website. I am looking for an easier way to make it appear the player is "stretching" their arm, then contracting back to normal size after an if statement, rather than doing this by creating a part with Instance.new() and welding it. Here is the method I have tried:

ArmStretch.Name = 'ArmStretchRight'
ArmStretch.Size = RightArm.Size
ArmStretch.Position = RightArm.Position
ArmStretch.Anchored = false
ArmStretch.TopSurface = 0
ArmStretch.BottomSurface = 0
ArmStretch.CanCollide = false
ArmStretch.Parent = Character
Weld(ArmStretch, RightArm, CFrame.new(0, 0, 0) * CFrame.new(0, 0, 0))
RightArm.Transparency = 1
RightHand.Transparency = 1
GomuStretchSndFX.Playing = true
GomuStretchSndFX.Parent = RightArm
while Keyframe == 'Pistol' do
	ArmStretch.Size = ArmStretch.Size + Vector3.new(0, 1, 0)
	ArmStretch.CFrame = ArmStretch.CFrame * CFrame.new(Vector3.new(0, 0.5, 0))
	ArmStretch.Position = ArmStretch.Position * Vector3.new(0, 0.5, 0)
	Weld(ArmStretch, RightArm, CFrame.new(0, 0, 0) * CFrame.new(0, 0, 0))
	if ArmStretch.Size.Y == 25 then
		ArmStretch.Size = ArmStretch.Size + Vector3.new(0, 1, 0)
		ArmStretch.CFrame = ArmStretch.CFrame * CFrame.new(Vector3.new(0, -0.5, 0))
		ArmStretch.Position = ArmStretch.Position * Vector3.new(0, -0.5, 0)
		Weld(ArmStretch, RightArm, CFrame.new(0, 0, 0) * CFrame.new(0, 0, 0))
		if ArmStretch.Size == RightArm.Size then
			break
		end
	end
	wait()
end

Weld Function:

function Weld(Part0, Part1, C0, C1)
	local nWeld = Instance.new("Weld")
		nWeld.Part0 = Part0
		nWeld.Part1 = Part1
		nWeld.C0 = C0 or CFrame.new(0, 0, 0)
		nWeld.C1 = C1 or CFrame.new(0, 0, 0)
		nWeld.Parent = Part0
	return nWeld 	
end

The variable for the part is "ArmStretch" and is assigned and creates the part with Instance.new() before the remoteevent function is fired. The weld function is in the ServerScript before the remoteevent function is coded. I'm asking this since I've had a lot of trouble trying to accomplish my goal with the method I just stated. The result has pretty much always ended up the same: the part increases in size in more than one direction rather than appearing to increase in size by only 1 direction. If anyone knows anything else that would work just as well, or better, please share. If anyone sees there is a problem, with the method I used, and can help me fix it, that would also be great. All help is appreciated.

Big Thanks!

5 comments

0

You could manually change the Size.

0

Please explain, what do you mean by manually change the size?

1

Part.Size = Vector3.new(x, y, z)

1

Or if you want to have it be an animation you could use tweening sevice

0

I see, I will try those out!