Good afternoon, this is my first post, so I hope it’s structured correctly. I need some script help please.
Problem
I’m currently creating an Obby and have a checkpoint system in place. (I don’t have spawn points because it works based off numbered parts that have their own folder.) The problem I have is people spawn into the void randomly. However, I need help to identify and fix it. (The output doesn’t show script errors either, so it’s hard to identify why it’s happening.)
About my checkpoint system
The scripts I have in place for the checkpoint system don’t live within the parts themselves, they’re one script file that lives in the ServerScriptService side of the game and it connects to the folder.
Things I’ve tried
-
I have tried making all the checkpoints “SpawnPoints” but they ignored my script and people kept spawning at a random spawn point.
-
I tried having one spawn point and the rest of the platforms numbered parts, again people kept spawning at the spawn point.
Here is the script I have setup for my checkpoints. (This script lives in the ServerScriptService) and (Progress is stored using a different script. I will upload my save script file too in case, that’s the culprit)
local Nodes = game.Workspace.Nodes
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local node = Instance.new("IntValue")
node.Name = "Node"
node.Value = 0
node.Parent = leaderstats
local prestige = Instance.new("IntValue")
prestige.Name = "Prestige"
prestige.Value = 0
prestige.Parent = leaderstats
player.CharacterAdded:Connect(function(char)
local hum = char:WaitForChild("Humanoid")
wait()
char:MoveTo(Nodes[node.Value].Position)
hum.Touched:Connect(function(hit)
if hit.Parent == Nodes then
if tonumber(hit.Name) == node.Value + 1 then
node.Value = node.Value + 1
end
end
end)
end)
end)
game.ReplicatedStorage.Prestige.OnServerInvoke = function (player)
if player.leaderstats.Node.Value == 41 then
player.leaderstats.Prestige.Value += 1
player.leaderstats.Node.Value = 0
player:LoadCharacter()
end
end
Here’s my saving script
local DataStoreService = game:GetService("DataStoreService")
local Nodes = DataStoreService:GetDataStore("Nodes")
local Prestige = DataStoreService:GetDataStore("Prestige")
game.Players.PlayerAdded:Connect(function(player)
local data
local success, errorMessage = pcall(function()
data = Nodes:GetAsync(player.UserId)
end)
if success then
player.leaderstats.Node.Value = data
else
warn(errorMessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local data
local success, errorMessage = pcall(function()
data = Nodes:SetAsync(player.UserId, player.leaderstats.Node.Value)
end)
if success then
print("Data Saved")
else
warn(errorMessage)
end
end)
game.Players.PlayerAdded:Connect(function(player)
local data
local success, errorMessage = pcall(function()
data = Prestige:GetAsync(player.UserId)
end)
if success then
player.leaderstats.Prestige.Value = data
else
warn(errorMessage)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local data
local success, errorMessage = pcall(function()
data = Prestige:SetAsync(player.UserId, player.leaderstats.Prestige.Value)
end)
if success then
print("Data Saved")
else
warn(errorMessage)
end
end)
game:BindToClose(function()
for i, v in pairs(game.Players:GetChildren()) do
v:Kick("Server Closed")
end
wait(2)
end)
Image 1 - ServerScriptService
Image 2 - ServerScriptService
Image 3 - Workplace.Nodes