DR1FTTR
(everett)
January 8, 2021, 9:38pm
1
When the player dies I want them to spawn at there home spawn, but everything I try doesent work. Please help.
script:
char.Humanoid.Died:Connect(function()
char.HumanoidRootPart.CFrame = newRoom:WaitForChild("Spawn").CFrame + Vector3.new(0,3,0)
end)
junekept
(junekept)
January 8, 2021, 10:12pm
2
You want to check for when the humanoid spawns, not when they die. You can use CharacterAdded
instead, which will fire when the player’s character spawns.
Edit: You can also use char:MoveTo() to move the model instead of using CFrame
1 Like
DR1FTTR
(everett)
January 8, 2021, 10:39pm
3
doesent work. player doesent go to the position.
1 Like
junekept
(junekept)
January 8, 2021, 10:43pm
4
Have you tried using MoveTo()? Also, CharacterAdded is an event of Player
, not Humanoid
DR1FTTR
(everett)
January 8, 2021, 10:44pm
5
yes, I have. I have no idea why it isent working.
DR1FTTR
(everett)
January 8, 2021, 10:48pm
6
This is what I did
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
char:MoveTo(workspace.PlayerRooms:FindFirstChild(player.Name…“Room”).Spawn.Position + Vector3.new(0,3,0))
end)
end)
Meat_Make
(Meat Make)
January 8, 2021, 10:53pm
7
can you try :SetPrimaryPartCframe instead?
junekept
(junekept)
January 8, 2021, 10:56pm
8
Strange, I just tested it in studio and it works fine if I make it wait for 3 second, but not without a wait
game.Players.PlayerAdded:Connect(function(player)
print("attatched to player")
player.CharacterAppearanceLoaded:Connect(function(char)
print("attatched to character")
print(char.Name)
wait(3)
char:MoveTo(workspace.Part.Position)
end)
end)
you can try this yourself, I have no idea why it doesn’t work especially since i used CharacterAppearanceLoaded
Edit: What have I done wrong with formatting this, does ``` not end a code block???
Thanks Vercte2 you saved my life
1 Like
Iinksafe
(LinkSafe)
January 9, 2021, 12:17am
9
Got the solution for your answer!
char.Humanoid.Died:Connect(function()
char.HumanoidRootPart.CFrame = newRoom:WaitForChild("Spawn").CFrame * Vector3.new(0,3,0)
end)
The operation you’re trying to use is +
, so we have to use *
.
Add a spawn point. That’s basically it.
Teo_O781
(Teo0781)
January 9, 2021, 12:25am
11
Simple solution which may work in this case, do :LoadCharacter on the player once the player dies, and then immediately set the humanoidrootpart cframe to whatever you want, this would work even if the server lagged.
What about Character:SetPrimaryPartCFrame()
?
You should’ve given more info, like what is the error.
This might work:
char.Humanoid.Died:Connect(function()
repeat wait() until char.Humanoid.Health ~= 0
wait(3)
char.HumanoidRootPart.CFrame = CFrame.new(newRoom:WaitForChild("Spawn").Position+ Vector3.new(0,3,0))
end)
However, you could just make a team spawnpoint instead of writing this unnecessary code.
DR1FTTR
(everett)
January 12, 2021, 4:30pm
14
My friend fixed it, thats the solution.