gara7722
(PercutiensIsOp)
June 14, 2024, 12:28pm
1
Hello. I wanna make character spawn in a spot, but the script doesn’t work and I don’t know why.
Here’s the code:
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character.HumanoidRootPart.CFrame = game.Workspace.SpawnPart.CFrame
end)
end)
1 Like
xyzdrej
(Andrej)
June 14, 2024, 12:38pm
2
Hey!
Your original code did work for me. However, here’s my version of your code:
game.Players.PlayerAdded:Connect(function(Player)
local Character = Player.Character or Player.CharacterAdded:Wait()
Character:MoveTo(game.Workspace.SpawnPart.CFrame.Position)
end)
Make sure there actually is a part named “SpawnPart” in the Workspace.
1 Like
Could you give some information about how the game is organised?
Like where is the script and are you getting any errors?
dso12red
(Yoriichi)
June 14, 2024, 12:39pm
4
User Character:PivotTo() as character is a model, it will move the whole model to that certain cframe.
gara7722
(PercutiensIsOp)
June 14, 2024, 12:41pm
5
Still doesn’t work. I don’t know what’s the problem, it doesn’t give me any errors.
gara7722
(PercutiensIsOp)
June 14, 2024, 12:42pm
6
The game is a roguelike dungeon game. No, it doesn’t give me any errors. The script is in StarterCharacterScripts.
Make sure the script is a server script and place it in serverscriptservice.
Or you could make it local and just replace it with:
local character = script.Parent
character:WaitForChild("HumanoidRootPart.CFrame"):PivotTo(workspace:WaitForChild("SpawnPart").CFrame)
gara7722
(PercutiensIsOp)
June 14, 2024, 12:45pm
8
Still doesn’t work.
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(character)
character:PivotTo(game.Workspace.SpawnPart.CFrame)
end)
end)
gara7722
(PercutiensIsOp)
June 14, 2024, 12:46pm
9
Thank you so much. I placed the script in wrong place.
Mark it as solution to close the thread
system
(system)
Closed
June 28, 2024, 12:58pm
11
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.