The Player.Character property does reference the new character overtime, however that’s after some time after respawning.
Shouldn’t Player.Character be nil if the player dies?
The Player.Character property does reference the new character overtime, however that’s after some time after respawning.
Shouldn’t Player.Character be nil if the player dies?
No, the character exists until the player despawns and a new character is parented to the workspace.
Ehh that’s not really something I would expect, yah I realized that after this test:
https://gyazo.com/a61c954e65b8fd902012cf6f49de2e18
Never once does it print nil for the character reference after the player dies. How would I grab the new character model?
This isn’t entirely surprising, this happens with the player instance itself as well. When the player leaves or is kicked, their parent is set to nil but they’re still in the game for a few seconds until the server fully removes them.
local Player = game.Players.LocalPlayer
local Character
spawn(function()
while wait() do
Character = Player.Character or Player.CharacterAdded:Wait()
end
end
local Root = Character:WaitForChild('HumanoidRootPart')
Root.Anchored = true
You can possibly try this. Not sure if it’ll work though.
I wouldn’t want a whole another loop for this, that doesn’t seem efficient. But if that’s the best soltution then i’m fine with it.
That would not work unless you’re constantly anchoring the rootpart inside the loop.
You could just use the CharacterAdded event and do it that way.
I’m not really sure why you want to constantly anchor a players HRP either.
I’m not constantly anchoring a player, that was an demo why this doesn’t work.
This is a big problem with by gun system since the character isn’t set to nil. I’ll try the CharacterAdded event.
Well then you can just have a CharacterAdded event on the localplayer and update whatever you need that way.
Yah that used to be my old way i’ll try that.
A CharacterAdded event in the local script would most-likely not work.
However keep in mind, not really sure if this applies to LocalScript’s in tools, when I used CharacterAdded in StarterPlayerScripts locally, it wouldn’t fire the event for the first time the player joined.
It does work, I tried this with my old gun system version when I did use CharacterAdded.
The only problem was when the player first joined it didn’t fire sometimes, I know how to fix that though.
What? That makes no sense, it works, just has issues on the first time around.
Also you could just grab the character model each time you need to use it.
It’s not the most efficient for local scripts.
By that I mean, workspace:FindFirstChild(LocalPlayer.Name)
.
I can’t really do that I have a lot of setup needed in the script. When the script starts running first I need to change their camera to my shouldercamera module.