Player Character spawning invisible

To see if its being changed, put a local script into your StarterCharacterScripts and put this code into it:

local char = game.Players.LocalPlayer.Character
for _, v in pairs(char:GetChildren()) do
	if v:IsA("BasePart") then
		v.Changed:Connect(function(prop)
			print(v.Name.. " has been changed and the property ".. prop.. " changed to "..tostring(v[prop]))
		end)
	end
end

But I’m not changing it. Here is the pet script

game.Players.LocalPlayer.Character:WaitForChild("HumanoidRootPart")
wait(1)
for _, player in pairs(game.Players:GetChildren()) do
	if player.Character then
		player.Character:WaitForChild("HumanoidRootPart")
		local PetLook = script.PetLook:Clone()
		PetLook.Parent = player.Character
		PetLook.CFrame = (player.Character.HumanoidRootPart.CFrame)
		print("Normal Pets")
		UpdatePets1(player)
		UpdatePets2(player)
	end
	player.CharacterAdded:Connect(function()
		player.Character:WaitForChild("HumanoidRootPart")
		local PetLook = script.PetLook:Clone()
		PetLook.Parent = player.Character
		print("CharacterAdded Pets")
		PetLook.CFrame = (player.Character.HumanoidRootPart.CFrame)
		UpdatePets1(player)
	end)
end

game.Players.PlayerAdded:Connect(function(player)
	if player.Character then
		player.Character:WaitForChild("HumanoidRootPart")
		local PetLook = script.PetLook:Clone()
		PetLook.Parent = player.Character
		PetLook.CFrame = (player.Character.HumanoidRootPart.CFrame)
		UpdatePets1(player)
		UpdatePets2(player)
	end
	player.CharacterAdded:Connect(function()
		player.Character:WaitForChild("HumanoidRootPart")
		local PetLook = script.PetLook:Clone()
		PetLook.Parent = player.Character
		PetLook.CFrame = (player.Character.HumanoidRootPart.CFrame)
		UpdatePets1(player)
	end)
end)

pets:GetPropertyChangedSignal("Value"):Connect(function()
	if pets.Value then
		for _, player in pairs(game.Players:GetChildren()) do
			UpdatePets1(player)
		end
	else
		for _, player in pairs(game.Players:GetChildren()) do
			if player.Character then
				for _, item in pairs(player.Character:GetChildren()) do
					if item:IsA("Model") then
						item:Destroy()
					end
				end
			end
		end
	end
end)

That’s the only code I have. After adding the wait(1) on line 2 it fixed it for some reason.

Try disabling that script and play again. If the problem continues then there is something wrong.
A virus or something.

After disabling it it doesn’t happen anymore. I’m not sure why though. There isn’t anything to do with setting any of the characters attributes in the script

It’s definitely something with the pets.
It’s not a virus or a freemodel(potentially).

It could probably be glitching the character out, or something related.

It’s definetly not a virus. I wrote everything myself. Here is the full script. Maybe I missed something

Removed to prevent people coping my code

Yeah we figured out its not a virus. It must be a glitch in the code.

You could make it so only when the character is loaded it will do the scripts, I’m not fully sure what is causing that bug, but I think this could help somewhat. If it does not help, tell me, and look in the output for any errors.

There aren’t any errors. And how am I meant to check if the player’s character is fully loaded in? I already have multiple :WaitForChild(“HumanoidRootPart”) statements to make sure the character is loaded in.

Okay, create a copy of your game. remove all the pets in the copy, then spawn in. if that doesn’t work, slowly, remove all the scripts in the copy, until the player spawns in. If that doesn’t work, I have no clue as to how your character spawns invisible. Also check if the characters body parts transparency property = 1, if it is, than magic is being used or something because I have no clue how it would be like that. Hope this helps.

But I already know which script is causing it. It’s the pet script for some reason. And it is setting the transparency property to 1. I’m not sure what happened because it worked perfectly for about a week and today it just kept making the player transparent. I’ve found a temporary fix by just adding a wait()

You can just overwrite that by setting the transparency to 0, that is my best solution, I would probably restart the whole pet system, and ask for tons of advice on the dev forum, but it might take longer than just figuring the problem out normally.

You can also check if a character is loading in by this:

local char = game.Players.AnotherScriptStudio.CharacterAdded:Wait()

If you do end up rewriting the pet system and would like a starting point you can watch this series from AlvinBlox. I highly recommend it.

I’m not going to rewrite it. I’m very happy with the one I wrote. I don’t see a point in rewriting all of it if there is a relatively simple way to fix it

This bug is so technical and specific that I don’t know why. It’s out of my range of understanding why. You should either hire a scripting master just to figure the code out for like 400 robux, and if you want to do it solo, than wait a while to find good scripters, than tell them about this. Most of my problems where just simple mistakes because I was coding for a long time and I got tired, but this is very confusing. Sorry that I couldn’t really help, It’s just very weird.

1 Like

The only unusual lines of code that I see are these specific ones here, maybe implement a check if the item’s name is equal to what you’re looping through instead of checking if the item is a Model

Other than that though that’s all that I see from your script

I changed it to

for _, item in pairs(player.PetData.Equipped:GetChildren()) do
					local item2 = player.Charatcer:FindFirstChild(item.Value)
					if item2 then
						item2:Destroy()
					end
				end

and it does seem to fix the issue. I don’t know why though. None of the players parts are models so it’s shouldn’t destroy them. Also it wasn’t destroying them but changing their transparency which is really weird. Thank you for your help

1 Like

My only assumption is that since there’s no wait() in your script, the script is running the moment the server is first created & apparently attempts to find your Character Model? No clue though

Also, you misspelled Character

As soon as I fixed that typo it made my character invisible the first time I joined. I give up with this. I’m just going to keep the wait, it seems like the wait is the only thing that works.

1 Like