Custom Character Help

image
This is the output.

Add a ) after the end on the last line

sorry edited and fixed i forgot to put an end)

But then on the fourth line, ServerStorage gets underlined.

just copy the edit and paste then testrun

On the fourth line, ServerStorage gets underlined.

that end) is underlined.


can u show me the script screenshot pls

i cant get u from here
charsss

An extra end wasn’t even needed, just a ) after the last end that existed in the code I posted

oh righht one sec charssssssssss

fixed full edited and fixed now try

image

It doesn’t show on the screenshot, but on the fourth line, ServerStorage is underlined.

make it game.ServerStorage charsssss

When I test it on roblox studio, it does nothing.

I just noticed @xperninshini changed the if statement. The condition in his if statement will never be true. The not operator first converts the name of char to false and after that, false is compared to “customchar”. And false is never equal to “customchar”. I have made this same name comparing mistake before. I’d recommend you to try my if statement.

Try putting a print statement within each if statement and see which if statements it gets to.

All of the current responses (except for the print to debug one) are wrong.

local fakeChar = game.ServerStorage['CharacterName'] -- The character to load, put it in ServerStorage
local respawnTime = 2.5 -- How many seconds the player remains dead before they respawn
game.Players.CharacterAutoLoads = false -- Disable default character loading
function playerAdded(player)
    if player.UserId == 0 then --replace 0 with your friends UserID
    if player.Character and player.Character.Parent then -- Destroy an already-existing character
    	player.Character:Destroy()
    end
    while player.Parent do -- Repeat until they leave the game
	    loadChar(player) -- Method waits until they die
	    wait(respawnTime)
	    end
	elseif player.UserId ~= 0 then -- Replace 0 with your friends userid
	    player:LoadCharacter()
    end
end
function loadChar(player)
    local char = fakeChar:clone()
    char.Name = player.Name
    local humanoid
    for i, child in pairs(char:GetChildren()) do -- Find the humanoid
        	if child.ClassName == "Humanoid" then
	    	humanoid = child
    		break
	    end
    end
    if not humanoid then -- If no humanoid was found, make one
    	humanoid = Instance.new("Humanoid", char)
    end
    player.Character = char
    char.Parent = game.Workspace
    humanoid.Died:Wait() -- Wait until they die
end
game.Players.PlayerAdded:connect(playerAdded)
for i, player in pairs(game.Players:GetPlayers()) do
    playerAdded(player)
end -- Credits to DaMrNelson for most of the script.

That is a script with comment lines for you on where to replace them with your values/data.

Make sure to put your custom character into ServerStorage and make sure that your character has the following 2 scripts/instances inside.

CustomInstance

If you still need help, please PM me on the devforum.

2 Likes

I agree. To fix it, I would change the
if not char.Name == "customchar" then
to
if char.Name ~= "customchar" then

That could work, but if @3vnp wanted to change the name of the character to the name of their friend, my if condition would work better. However, the code posted by @Sudden_Demise might be a better solution than my code would be even with the syntax fixes. My solution might be hacky and cause problems in other systems in the game, because there’s some extra character added firing.

1 Like