Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

Some players don't spawn on the Checkpoint they are on?

Asked by 4 years ago
Edited 4 years ago

Hi I am Rob and I have been using Roblox Studio for a week.

So basically I have been trying to create a checkpoint system using a StartSpawn and a few Checkpoint blocks. It worked perfectly for all the users who played but one of my friend says that even if touched his current checkpoint, he would still respawn back to the StartSpawn If there is a better way of doing this or some improvements please leave an answer!

My current script (copied it from the "Obby" template by the way):

local spawn = script.Parent
spawn.Touched:connect(function(hit)
if hit and hit.Parent and hit.Parent:FindFirstChild("Humanoid") then
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
local checkpointData = game.ServerStorage:FindFirstChild("CheckpointData")
if not checkpointData then
checkpointData = Instance.new("Model", game.ServerStorage)
checkpointData.Name = "CheckpointData"
end
local checkpoint = checkpointData:FindFirstChild(tostring(player.userId))
if not checkpoint then
checkpoint = Instance.new("ObjectValue", checkpointData)
checkpoint.Name = tostring(player.userId)
player.CharacterAdded:connect(function(character)
wait()
character:WaitForChild("HumanoidRootPart").CFrame = game.ServerStorage.CheckpointData[tostring(player.userId)].Value.CFrame + Vector3.new(0, 4, 0)
end)
end
checkpoint.Value = spawn
end
end)

2 answers

Log in to vote
0
Answered by 4 years ago

Did you know that Roblox has a system like this built-in? It's pretty neat.

You can match a spawn block with a team through the properties of the spawn block. Here is a picture of what the settings look like. For example, you can have a spawn block that ONLY red team can use. Furthermore, you can also have a spawn block for ONLY blue team.

In order to do this, change the Neutral field to false and change the TeamColor to the BrickColor value that you have the team as.

If this helped out, consider accepting this answer for those sweet, sweet reputation points. If not, comment below and I'll help you out.

0
Hmm I have tried that before but sometimes it is a little buggy because whenever I test it Teams always mess up and etc. robthepoop123 9 — 4y
0
And also if you do that over and over it gets kinda boring and also you might run out of colors in the palette robthepoop123 9 — 4y
0
@robthepoop123 Can you tell me what you mean by buggy? I've used it and have found it perfect for what I need, you just need to set it up correctly. Also, the color palette is HUGE. If you do somehow manage to have that many teams, then spawnpoints are the least of your worries. TaxesArentAwesome 514 — 4y
Ad
Log in to vote
0
Answered by
d1_rek 46
4 years ago

If you want it to be with the same color just insert this into the block-

game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(char)
    local Team = plr.Team
    char:MoveTo(game.Workspace:FindFirstChild(Team.Name))
end)
end)

This should work, if it doesn't look into the errors by pressing f9.

0
Sorry but I don't really like working with TeamColors I want like the "Name" of the Team (i.e Stage1) if you get what I mean robthepoop123 9 — 4y

Answer this question