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

what is the best way to make Custom Character depending on Player Race?

im trying to make a script that changes player body to a "monster like" depending on the race, there is 4 of these monsters, each one with a specific body, i did it with a ServerScript and doing this:

if race.Value == "hollow" then
	local newChar = hollow:Clone()
	newChar.Name = plr.Name
	newChar.Parent = W
	newChar.PrimaryPart = newChar.HumanoidRootPart
	newChar.PrimaryPart.CFrame = plr.Character.PrimaryPart.CFrame
	plr.Character = newChar
	game.ReplicatedStorage:WaitForChild("CameraFix"):FireClient(plr)
end

its the best way? make in a ServerScript and do all these things or theres a way to just change the player "StarterCharacter"? i think in a LocaScript, something like "if your race is X, ill clone the X body in your StarterPlayer and rename it StarterCharacter" what u guys think about it?

1 answer

I'm no expert at all, but I would probably put the monster bodies in something like replicated storage or whatever, and run something like this:

if race.Value ~= nil then
	local body = game.ReplicatedStorage:FindFirstChild(Race.Value):Clone()
	body.Parent = newChar
	--everything else blah blah
	print("Mwahaha you are now a... "..race.Value.."!!!")

That way you aren't running numerous "if race.Value == this, and if race.Value == that", etc.

3 comments

0

i need those "if race.Value == this then do this", because its 4 monsters and each one is for a specific level and have specific body, so i cant just do "race~=nil" and make 1 morph, this is not what i want, and "hollow" in my script is already in ReplicatedStorage

0

Totally, but if you do race.Value ~= nil, then you already know what their monster is because you have race.Value instead of running if-statements. So you could just use race.Value to find the morph out of the 4 in replicated storage. On Line 2 of the code I put, that would find the specific morph out of the 4.

0

Just a suggestion though to make code neater, whatever's easiest for you.

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