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

Why will the LocalTransparencyModifier not work in this script?

So I need to make a Draw Weapon system. I've done it, but the LocalTransparencyModifier won't show the gun or body parts. This is an FPS game so I need all the parts to be locally visible to the client.

Here's my script (the important bit, and it is a LocalScript):

--The main getting input bit is up here, don't worry about that.
if input.KeyCode == Enum.KeyCode.One then
				if workspace.GameVals.DrawGunAllowed.Value == true then
					if holdingWeapon == false then
						holdingWeapon = true
						player.PlayerGui.DrawWeapon.DrawPistol:FireServer(player, "Suppressed Phoenix", "Draw")
						SEvent:FireServer(player.PlayerGui.MainStats.Status, "Text", "Armed")
						SEvent:FireServer(player.PlayerGui.MainStats.Status, "TextColor3", Color3.fromRGB(170, 0, 0))
						player.Character.LeftUpperArm.LocalTransparencyModifier = 0
						player.Character.LeftLowerArm.LocalTransparencyModifier = 0
						player.Character.LeftHand.LocalTransparencyModifier = 0
						player.Character.RightUpperArm.LocalTransparencyModifier = 0
						player.Character.RightLowerArm.LocalTransparencyModifier = 0
						player.Character.RightHand.LocalTransparencyModifier = 0
						local gun = player.Character:WaitForChild("Suppressed Phoenix")
						local parts = gun:GetChildren()
						for i = 1,#parts do
							if parts[i].ClassName == "MeshPart" or parts[i].ClassName == "UnionOperation" then
								parts[i].LocalTransparencyModifier = 0
							end
						end
					elseif holdingWeapon == true then
						holdingWeapon = false
						workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
						Scoped = false
						player.PlayerGui.DrawWeapon.DrawPistol:FireServer(player, "Suppressed Phoenix", "Put Away")
						SEvent:FireServer(player.PlayerGui.MainStats.Status, "Text", player.OriginStatus.Value)
						SEvent:FireServer(player.PlayerGui.MainStats.Status, "TextColor3", Color3.fromRGB(255, 255, 255))
						player.Character.LeftUpperArm.LocalTransparencyModifier = 1
						player.Character.LeftLowerArm.LocalTransparencyModifier = 1
						player.Character.LeftHand.LocalTransparencyModifier = 1
						player.Character.RightUpperArm.LocalTransparencyModifier = 1
						player.Character.RightLowerArm.LocalTransparencyModifier = 1
						player.Character.RightHand.LocalTransparencyModifier = 1
					end
				end

By the Way, the SEvent is a RemoteEvent that when fired by a LocalScript, will change something for the Server. The Event System goes like this: SEvent:FireServer([Item, like a TextLabel goes here], [Property of item goes here], [Property status goes here])

Also, the DrawPistol event will deal with playing the weapon animation and making a weapon connect to the player's character.

Hopefully, somebody can help me. Thx!

1 answer

I think you should use the UserInputService to call your function and integrate checking for Keycode.One, into it. Otherwise, your code above may only run once, and never again.. you need an input event service to call it, based on user input, for any of the above to work.

2 comments

0

I already got that bit. It wasn't related to what I need. If I go to server then my character is holding the weapon, but through the client all the parts are still at 1 LocalTransparencyModifier.

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