No UpperTorso found when trying to change transparency

I’m trying to change the transparency of the players UpperTorso, but it won’t work. It gives me a warning stating and Infinite Yeild is possible but when I check my character model it is there.

script (I took it from the Api reference and then changed it, so I’m super lost):

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player:WaitForChild("Character")

if not character or not character.Parent then
	print("No character found.")
else
	character.UpperTorso.Transparency=1
end

location of script and what type of script

Locally inside of StarterPlayerScripts (which is in StarterPlayer)

move it to starterGui or StarterCharacterScripts

(starterGui if you are doing stuff to player and character)

local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

if not character or not character.Parent then
	print("No character found.")
else
	character.UpperTorso.Transparency=1
end

try printing variables and see what are they thats how debugging works

he has it in starterplayerscript its impossible to access player character from there

I moved it to StarterCharacterScripts and I tried the script that @hakobmher said. Both of you were right so thank you, both of you.

They are running in starterplayerscript i tried it myself and it works im pretty sure local scripts works both on startercharacterscripts and starterplayerscripts

Edit: i tried it min ago to be extra clear tho

oh, when i tried awhile back it didn’t work (with localscript)