#Error: character cannot be changed as Player (Player name) is being removed

30 messages · Page 1 of 1 (latest)

mint ginkgo
#

I have an error that I have never seen before and I am hoping someone knows what the issue is. The error pops up everytime a player joins the game for the client that is already in the game.

grizzled ice
#

Send me the code where the error is occuring

mint ginkgo
#
local players = game:GetService("Players")
local Player = players.LocalPlayer or players.PlayerAdded:Wait()

game:GetService("RunService").RenderStepped:Connect(function() 
    for _, v in pairs(players:GetPlayers()) do
        if v.Character and v ~= game.Players.LocalPlayer then
            local char = v.Character or v.CharacterAppearanceLoaded:Wait()
                if char then
        for _, v in pairs(char:GetChildren()) do
                
                if v:IsA("MeshPart") or v:IsA("BasePart") then
                                    
                    v.Transparency = 1
                end
            
                if v:IsA("Decal") then
                    v.Transparency = 1        
                    end
                end
            
            end
        end
    end
end)
#

the code is kind of a mess because ive been messing with it trying to come up with any sort of solution

grizzled ice
#

I think its because you're using the same variable "v" twice for player:GetPlayers() and char:GetChildren()

#

The game doesnt know if your v variable is referring to the player or the actual player character @mint ginkgo

mint ginkgo
#

The thing is thought it works for already existing players

#

basically new player joins it breaks for old player but works for new player

#

I'll try changing the variable

grizzled ice
#

Lmk if that fixes the issue

mint ginkgo
#
local players = game:GetService("Players")
local Player = players.LocalPlayer or players.PlayerAdded:Wait()

game:GetService("RunService").RenderStepped:Connect(function() 
    for _, v in pairs(players:GetPlayers()) do
        if v.Character and v ~= game.Players.LocalPlayer then
            local char = v.Character or v.CharacterAppearanceLoaded:Wait()
                if char then
        for _, y in pairs(char:GetChildren()) do
                
                if y:IsA("MeshPart") or y:IsA("BasePart") then
                                    
                    y.Transparency = 1
                end
            
                if y:IsA("Decal") then
                    y.Transparency = 1        
                    end
                end
            
            end
        end
    end
end)
#

dont worry about the noob look thats just something having to do with roblox character override being weird

#

I managed to pump out of a solution that avoided the error

grizzled ice
#

How

mint ginkgo
#

What do all characters share?

#

man can't believe it works

mint ginkgo
# mint ginkgo What do all characters share?

alr figured you were going to guess or ask but you havent SO bottom line all players share humanoid,HRP, and depending on game settings, Torso, UpperTorso etc etc. Instead of going through the players in players and then searching for them in workspace you just search for any model with a humanoid in workspace and if the model name ~= localplayer then you do the transparency stuff

#

Sure this applies to any humanoid character BUT quick fix to that is looking for v.name rather than v:IsA and renaming all npc humanoids to npc or monster or whatever

grizzled ice
#

I think the main issue though was with client to server replication. All of the player character models are being updated constantly and you're constantly looking through the players when they might not be completely replicated

#

There's also some other stuff behind the scenes I think that plays a role in that error

#

It's better to disconnect the event if you're using it only once when a specific local player joins

#

RenderStepped can be very costly

mint ginkgo
mint ginkgo
#

Overall its going to be used for a player hider system

#

so I have a while var = true do thing so they can turn it on and off

grizzled ice
#

I see

#

What game are you making?