Hello, in my game, I have the character's arms visible in first person, but I find it that when scoped in with a sniper rifle, the arms remain in the way, obstructing view. Here's my code for it;
local player = game.Players.LocalPlayer; local rs = game:GetService("RunService"); local character = player.Character local camera = game.Workspace.CurrentCamera rs.RenderStepped:Connect(function() if not player.Character:FindFirstChild("Sniper Rifle") then --if they have any other weapon out... character["Right Arm"].LocalTransparencyModifier = 0 character["Left Arm"].LocalTransparencyModifier = 0 else --If they do have a sniper equipped... character["Right Arm"].LocalTransparencyModifier = 1 character["Left Arm"].LocalTransparencyModifier = 1 end end)
I don't fully understand LocalTransparencyModifier, so any and all help on it would be greatly appreciated!
Ok, so you said you want a walkthrough. According to this developer.roblox.com post,
The LocalTransparencyModifier property is a multiplier to BasePart.Transparency that is only visible to the local client. It does not replicate from client to server. It is useful for when a part should not render for a specific client, such as how the player does not see their character’s body parts when they zoom into first person mode.
This is similar to your problem, here is a code sample that I have added notes to, to better help you understand:
local player = game.Players.LocalPlayer; --make sure you run game.Players.LocalPlayer in a LocalScript, otherwise it won't work. local rs = game:GetService("RunService"); local character = player.Character local camera = workspace.CurrentCamera --changed from game.Workspace to workspace local leftArm, rightArm; -- define these ahead of time rs.RenderStepped:Connect(function() if not character:FindFirstChild("Sniper Rifle") then --if sniper isn't equipped leftArm.LocalTransparencyModifier = 0; --sets the left arm to 0 transparency rightArm.LocalTransparencyModifier = 0; --sets the right arm to 0 transparency elseif character:FindFirstChild("Sniper Rifle") then --if sniper is equipped leftArm.LocalTransparencyModifier = 1; --sets the left arm to 1 transparency rightArm.LocalTransparencyModifier = 1; --sets the right arm to 1 transparency end; end);
Not sure if this works, made it up in my head.