Character can't be accessed from local script

I am making a pet gamepass feature for a game. I made a “Show Pets” button. For some reason, it won’t work. The event fires because the button color changes from green to red, but the pets do not become invisible. The pets are not models. I know it is possible because when I directly reference my character in the game, the pet transparency goes from 0 to 1 and it becomes invisible. Also, there are no errors in the output. The script is located in StarterGui under an image button. Here is the code:
Thanks for your help!

local value = true
repeat wait() until game:IsLoaded()
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local character = player.Character
if not character or not character.Parent then
	character = player.CharacterAdded:wait()
end
script.Parent.MouseButton1Down:Connect(function()
	if value == true then
		value = false
		script.Parent.ImageColor3 = Color3.new(1, 0, 0)
		character.Doge.Transparency = 1
		
	else
		value = true
		script.Parent.ImageColor3 = Color3.new(0.231373, 1, 0)
		character.Doge.Transparency = 0
	end
	
end)

You should probably capitalise that ‘Wait()’ there in your characteradded line.

repeat task.wait() until game:IsLoaded() task.wait(1)
local plr = game.Players.LocalPlayer
local char = plr.Character
local value = true

script.Parent.MouseButton1Down:Connect(function()
	if value == true then
		value = false
		script.Parent.ImageColor3 = Color3.new(1, 0, 0)
		character.Doge.Transparency = 1
		
	else
		value = true
		script.Parent.ImageColor3 = Color3.new(0.231373, 1, 0)
		character.Doge.Transparency = 0
	end
	
end)

Not saying this will work you just had a lot of unneeded stuff typed.

Yeah, unfortunately it didnt work

Retype the values I didnt fix also if you didnt do that lmao. I changed the value from character to char. **

Yeah I noticed that and fixed it, It still doesnt work

local Value = true
repeat wait() until game:IsLoaded()
local Players = game:GetService("Players")
if script:IsA("Script") then print("Running on server") end
local Player = Players.LocalPlayer
local Character = Player.Character
Pets = {[1] = "Doge"} -- First index is doge
Index = 1
script.Parent.MouseButton1Down:Connect(function() 
if Value == true then Value = false script.Parent.ImageColor3 = Color3.new(1, 0, 0); Character[Pets[Index]].Transparency = 1 else Value = true script.Parent.ImageColor3 = Color3.new(0.231373, 1, 0) Character[Pets[Index]].Transparency = 0 end
end)

Not sure if it would work, go try

Yeah, it didn’t work sorry. I think the problem is the character being referenced incorrectly

or you cant parent the doge instance to the character? give us the output error or something

repeat task.wait() until game:IsLoaded() task.wait(1)
local plr = game.Players.LocalPlayer
local char = plr.Character
local value = true

script.Parent.MouseButton1Down:Connect(function()
	if value == true then
		value = false
		script.Parent.ImageColor3 = Color3.new(1, 0, 0)
		--char.Doge.Transparency = 1

	elseif value == false then
		value = true
		script.Parent.ImageColor3 = Color3.new(0.231373, 1, 0)
	--char.Doge.Transparency = 0
	end

end)

Just took this into studio, works perfectly fine so idk what youre talking about mate.

Which is strange because I used a character reference script from the dev wiki

LocalScript - Roblox Studio (gyazo.com)

see works perfectly fine.

It actually does work, I made it so after it changes transparency it prints “sus” and it prints maybe its a problem with the mesh itself

question, is doge an accessory? If is you have to access the basepart that it has.
The basepart is called handle. Also it wont show serverside hoping you already know that.

No its not, its a mesh part. Its so weird because it prints as if there were no errors but it doesn’t work

I’m going to retest but this time i will delete the texture

Is doge the actual name and is it actually in the character by time youre checking? Cuz I can run this on my mesh and itll work perfectly fine there has to be some like specific reason to why its not working

It is in the character yes and “Doge” is the name

I just tested it and it worked the problem was it was a part with a mesh and not a mesh part