Character shows while in first person in studio but never in game

So I have a script designed to make the players character visible while in first person, It works 80% of the time in studio making the character visible, in every testing play it prints out the statement saying it was made visible, but in the ROBLOX Game it will print it out then keep the player completely transparent

Script:

local char = player.Character or player.CharacterAdded:wait()
local humanoid = char:WaitForChild("Humanoid") -- waits for the humanoid in the character



function antiTrans(part)
	if part and part.Name=="LeftUpperArm"  or part.Name=="LeftLowerArm" or part.Name=="LeftHand" or part.Name=="RightUpperArm" or part.Name=="RightLowerArm" or part.Name=="RightHand" or part.Name== "UpperTorso" or part.Name=="LowerTorso" or part.Name=="LeftLowerLeg" or part.Name == "LeftUpperLeg" or part.Name == "LeftFoot" or part.Name == "RightUpperLeg" or part.Name == "RightLowerLeg" or part.Name == "RightFoot" then -- checks if a part and is a arm
		part.LocalTransparencyModifier = part.Transparency
		print(part, "Set")
		part.Changed:connect(function (property)   
			if part.LocalTransparencyModifier == 1 then
				print(part, "Set")
			part.LocalTransparencyModifier = part.Transparency--Changes the local modifyer(client side only)
			part.CastShadow = false
			end
		end)
	end
end

for _,v in pairs(char:GetChildren()) do
	antiTrans(v) -- adds all parts
end

You need to set the .LocalTransparencyModifier everytime RenderStepped fires, example code is this…

local Character = script.Parent
local RunService = game:GetService("RunService")

RunService.RenderStepped:Connect(function()

coroutine.wrap(function() -- Incase there's any delay
for _,Parts in Character:GetChildren() do
If Parts:IsA("BasePart") and Parts.Name ~= "Handle" then
Parts.LocalTransparencyModifier = 0
end
end
end)()

end)

I would rewrite your code like this


local char = player.Character or player.CharacterAdded:wait()
local humanoid = char:WaitForChild("Humanoid") -- waits for the humanoid in the character



function antiTrans(part)
	if part and not part.Name == “Head” then
		part.LocalTransparencyModifier = 0
		print(part, "Set")
		part.Changed:connect(function (property)   
			if part.LocalTransparencyModifier == 1 then
				print(part, "Set")
			part.LocalTransparencyModifier = 0--Changes the local modifyer(client side only)
			part.CastShadow = false
			end
		end)
	end
end

for _,v in pairs(char:GetDescendants()) do
	antiTrans(v) -- adds all parts
end 

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.