|
| 28 Mar 2017 11:40 PM |
I have been wondering about this because of an issue I am experiencing with a localscript. The script is in ReplicatedFirst and CharacterAutoSpawns is disabled.
Here is the script, if I remember correctly.
character = Instance.new ("Model", game.Workspace) game.Players.LocalPlayer.Character = character -- I am worried about this line character.Name = game.Players.LocalPlayer.Name -- I can't retrieve the Name either.
As you can tell, when the game is a run, a new model is created. The script attempts to set the player's character to the model, however it does not set it, and it seems to be Nil when run. I also can't retrieve the name of the player, which I would like to name the model.
Sorry for such a simple question guys, I'm sure the answer was obvious. Thanks for the help! |
|
|
| Report Abuse |
|
|
devHoodie
|
  |
| Joined: 04 Nov 2008 |
| Total Posts: 30332 |
|
|
| 28 Mar 2017 11:41 PM |
If you want to have a custom character
just make the character model
and place it in StarterPlayer called
StarterPlayerCharacter
-- Former AKA : luis15232 |
|
|
| Report Abuse |
|
|
Roblok1
|
  |
| Joined: 27 Jul 2011 |
| Total Posts: 2019 |
|
|
| 29 Mar 2017 01:40 AM |
or, if you want different people to be different custom characters... then just set the character property to any object that is of type "Model"
|
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 05:51 AM |
Player.Character is writable. Although you could have tested that yourself with ease.
|
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 08:50 PM |
/devHoodie/ Thanks for the info, but I have already attempted using this and it just doesn't seem to be what I am looking for. I plan to have a control scheme and "feel" that is completely different from the default control method. Basically I want the character to be a single block with a few BodyMovers inside to control it. I have used the method you described before and it seems to break more things than it fixes, at least in my goal.
When a character spawns using this method, the game also adds all the player control scripts that are there by default. I have gotten around this earlier by deleting the characters children after the character loads but I feel it is much more elegant and cleaner to simply never spawn the default character at all and instead disable CharacterAutoLoads.
Thanks for your reply, but am I on the right track in my method? Why doesn't mine seem to work, especially if the Character property of Player should be writable.
///
/Roblok1/ So the class of the character just has to be "Model"? Am I doing something wrong, then?
///
/SquidyBroh/ And I did. I attempted setting the character property to a model in the workspace, which did not seem to work.
///
Thank you all for the replies, but I am afraid these aren't exactly the answer I was looking for. I should have been more specific about my goals in the Original Post.
Thanks, all, for your time and replies! |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 08:50 PM |
Just a question, is the custom character going to be the same for all players?
|
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 08:53 PM |
Thanks for the response. The goal is to have a character which the user can choose depending on their progress in the game. I intend to have many different "characters" but they should all function almost exactly the same. Thanks! |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 29 Mar 2017 08:56 PM |
A character requires a torso,humanoid,and head iirc
How do you think morphs work?
Yes you can change the character.
|
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 08:58 PM |
"I feel it is much more elegant and cleaner to simply never spawn the default character at all and instead disable CharacterAutoLoads."
That's honestly the way I'd do it. Can you post the code that isn't working?
|
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 08:58 PM |
Would'ya look at that. It seems to work for the most part. The problem comes when retrieving the players name. I am super confused about why it's not working because it should be super super simple. What I am trying to do:
character.Name = game.Players.LocalPlayer.Name
That really should work, in my head at least. Instead I just end up with a model named "Model". I can't even print the Player's name.\ Thanks all. |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 08:59 PM |
Don't handle this locally, because you'll run into issues if you enable FilteringEnabled.
|
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 09:04 PM |
/TimeTicks/ I already replied to something sort of similar. I understand it is possible to change the character. I have a strong feeling I know how to do this. There is, however, a minor problem I am experiencing, unrelated to the default character.
Sorry for being a bit hostile, I'm a bit frustrated that few seem to understand my question is all.
Sorry.
/Unsubtleties/ Here is my broken code character = Instance.new("Model", game.Workspace) game.Players.LocalPlayer.Character = character character.Name = game.Players.LocalPlayer.Name -- This part doesn't seem to work.
///
I understand issues may arise should I enable Filtering, however I believe I can tackle the issue when it comes.
Thanks, all.
Sorry if I can't keep up with this thread.
|
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 09:07 PM |
You're most likely receiving that error because of how ROBLOX handles characters. Change the properties of the character Model before assigning it to the Character property.
That's really how it should always be; it's more efficient to adjust properties before parenting it and having it rendered.
|
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 09:09 PM |
I believe I have found a way to find the LocalPlayer's name.
I have set the variable plr to game.Players.LocalPlayer and then use plr.Name to retrieve it instead of game.Players.LocalPlayer.Name.
However I can't set the model's name to the player's name, but I can at least print it now.
I can't believe I am posting on the forums because I am having trouble naming a model.
Lol. |
|
|
| Report Abuse |
|
|
| |
|
|
| 29 Mar 2017 09:10 PM |
What
model.Name = game.Players.LocalPlayer.Name |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 09:11 PM |
local player = game:GetService("Players").LocalPlayer -- it's a good idea to call GetService() on the client (or server too if FilteringEnabled is not enabled); the client could maliciously change the name of the service
local character = Instance.new("Model") character.Name = player.Name -- assign properties/add objects before parenting character.Parent = workspace player.Character = character
|
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 09:11 PM |
| And would ya' look at that. It is working now. Thank you very much for your persistent help, Unsubtleties! :) |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2017 09:12 PM |
Oh, I thought you posted after reading my last reply before that. No problem.
|
|
|
| Report Abuse |
|
|