Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Changing a player to a model?

Asked by
PredNova 130
9 years ago

I'm trying to make it so that when a player joins the game, the players character will be replaced with a model of mine. When it works, it should be able to do the same thing a normal player can, except the players image is different. (Pretty much a morph, but without any buttons and only a simple script)

This is a local script inside StarterGUI

wait(2)
local plr = game.Players.LocalPlayer
    plr.Character:ClearAllChildren()
    game.Workspace.Chicken:MakeJoints()
    plr.Character = Workspace.Chicken

The script works to some extent. The players character is removed and the chicken seems to disappear but does not end up replacing the character and while the character is missing, I can't move. There's no outputs.

Thanks for helping. :)

0
Also, press Accept Answer next to my answer if I helped a little. EzraNehemiah_TF2 3552 — 9y
0
You're welcome! EzraNehemiah_TF2 3552 — 9y

1 answer

Log in to vote
2
Answered by 9 years ago

Well, here are the problems. 1.) Character might not be loaded yet 2.) Character's body parts will fall off. 3.) Character is an Object value.


To wait for the character to load you must do this:

local character = plr.Character
if not character or not character.Parent then
    character = plr.CharacterAdded:wait()
end

To make the model stick you must make joints after everything else:

wait(2)
local plr = game.Players.LocalPlayer
    plr.Character:ClearAllChildren()
    game.Workspace.Chicken:MakeJoints()
    plr.Character = Workspace.Chicken
--Will Break apart

wait(2)
local plr = game.Players.LocalPlayer
    plr.Character:ClearAllChildren()
    plr.Character = Workspace.Chicken
    plr.Character:MakeJoints()
--Will not

Characters can't change value:

game.Players.LocalPlayer.Character = "Hi"
--Will error

The reason you cant move is because you don't have a 1.) Humanoid 2.) Animation Script 3.) Other vital movement stuff. This is all because you cleared the character's children.


If you want, you can use this script:

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        player.CharacterAppearance = "http://www.roblox.com/Asset/CharacterFetch.ashx?userId=13667373&placeId=0" --This is to look like me! Replace the "13667373" with a players ID.
        player:LoadCharacter()
    end)
end)

Now just make a second roblox account and give it clothes to look like the chicken. Then you can replace "13667373" with the new accounts user ID.


If the chicken is not the same shape as a normal player, you can do this:

game.Players.PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character.Torso.CFrame = CFrame.new(character.Torso.CFrame) * CFrame.Angles(5,0,0) --Or something
        character:MakeJoints()
    end)
end)


Some of these scripts are just ideas.


Hope it helps!

0
Thanks for the reply! This seems to be harder than first expected, haha. Is there any way that I could literally just change the players character to the chicken without it moving? (I'll script something seperate for movement, and the chicken is made of blocks) Or would it just be easier to use a morph and then teleport the player to where I need them when they've changed? PredNova 130 — 9y
0
@ PredNova , maybe you can get a model or something. Maybe you could teleport after they spawn. Just try your best. EzraNehemiah_TF2 3552 — 9y
0
Just played about with a few morphs and works fine, But thank's for your reply, Learnt alot from it =) PredNova 130 — 9y
Ad

Answer this question