#Problem With Character Changing

6 messages · Page 1 of 1 (latest)

vital delta
#

Ok so, im making a battlegrounds game where you turn into the characters. the thing is though, when i do it it has a weird problem where it takes a bit, it traps my camera in the void for a bit, and the camera doesnt even go along with it. No animations either. i also get some weird errors.

anyways heres the script

local Players = game:GetService("Players")

Players.PlayerAdded:Connect(function(player)
    player.CharacterAdded:Connect(function(char)
        local characterName = player:FindFirstChild("selectedstuff") and player.selectedstuff:FindFirstChild("Character")

        if characterName then
            local model = ServerStorage:FindFirstChild(characterName.Value)

            if model then
                local newChar = model:Clone()
                newChar.Parent = workspace
                newChar:SetPrimaryPartCFrame(char.PrimaryPart.CFrame) 
                player.Character = newChar
            end
        end
    end)
end)```
smoky lance
vital delta
#

ohhh ok

#

do you know any way i can fix it???

faint mantle
# vital delta Ok so, im making a battlegrounds game where you turn into the characters. the th...

you are setting player.Character inside the player.CharacterAdded event, which fires the CharacterEvent added a second time, which changes the player.Character again firing CharacterAdded for a third time, which changes the player.Character again firing CharacterAdded for a 4th time, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, which changes the player.Character again firing CharacterAdded again, ... ad infinitum

#

this is what "maximum re-entrancy" is referring to