Answered by
5 years ago Edited 5 years ago
Your code is almost right. My way to do this would be to create a dictionary of players' spawn positions, then update those when they touch something. Then for every who joins I'd connect to their characteradded and move them there. Example below:
01 | local folder = game.Workspace.Folder |
03 | local playerpositions = { } |
04 | local spawnpoint = game.Workspace.SpawnPoint |
06 | for i, v in next , folder:GetChildren() do |
07 | if v:IsA( "BasePart" ) then |
08 | v.Touched:Connect( function (hit) |
09 | local plr = game.Players:GetPlayerFromCharacter(hit.Parent) |
11 | if plr = = nil then return end |
13 | playerpositions [ plr ] = v.Position |
19 | game.Players.PlayerAdded:Connect( function (plr) |
20 | local leaderstats = Instance.new( "Folder" ) |
21 | leaderstats.Name = "leaderstats" |
22 | leaderstats.Parent = plr |
24 | local checkpoints = Instance.new( "IntValue" ) |
25 | checkpoints.Name = "Stages" |
26 | checkpoints.Parent = leaderstats |
28 | plr.CharacterAdded:Connect( function (char) |
29 | char:MoveTo(playerpositions [ plr ] or spawnpoint.Position) |
Reply with further questions,
and please mark as correct if this solution works for you!