Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

I am trying to name a model but it stops the rest of the script from working?

I have it so that when you join, ur character is destroyed and replaced with a clone of a model in replicated storage. it all works, but when you enter the game, in workspace, ur character is called something else and I wanted to name it back to the players name. Heres my code:

local event = game.ReplicatedStorage.ChangeChar -- Character change 


event.OnServerEvent:Connect(function(player,model)
wait(.1)
	local Char = model:Clone()
	local Pos = player.Character:GetPrimaryPartCFrame()
	player.Character:Destroy()
	player.Character = Char
	Char.Parent = workspace
	Char:SetPrimaryPartCFrame(Pos)
	Char.Name = player.Name
end)

adding Char.Name = player.Name causes you to spawn as your avatar and not the model.

1 answer

You can just move the replacement model into StarterPlayer and rename it to "StarterCharacter" and roblox will handle this all for you (including renaming the model to the player's name.)

2 comments

0

The thing is, as a part of the game, as you progress, your character changes model so its not just 1 at all times

0

Oh. If you rename the character model before destroying the player's character work?

This discussion is preserved as it was. New answers, comments, and votes are closed.