I’m making a checkpoint system, the thing is, when you rejoin and it tries to send you to the stage you got to, it can’t because roblox doesn’t load stuff in when it’s far away. Does anyone know a way to load everything in from the start, or, probably more optimally, load everything inside the “Checkpoints” folder in the workspace?
just do :WaitForChild(workspace.Checkpoints) or add a loading screen
I’m not 100% sure on what to put before the colon, but I tried this and it didn’t work (Checkpoints_Holder is the folder):
game:WaitForChild(workspace.Checkpoints_Holder)
I already have a :waitforchild thing when it tries to send you to the checkpoint, is there a way to force something to load in regardless of its distance?
local checkpoints_folder = workspace:WaitForChild("Checkpoints_Holder")
Also certainly! I heard that if you put the folder in ReplicatedFirst its the first thing that loads.
I have that code already in the script. I don’t think roblox cares about :waitforchild’s if the object’s too far away to load.
I’ll try putting the folder inside replicatedfirst and then taking it out via script when you join.
Can u provide us with your code, it would make it easier for us to assist u.
Sure, pretty sure it’s irrelevant to the problem, but maybe I’m wrong, idk. The stuff at the top messed it up so I’ma remove it lol:
warn("[Game Loading]")
wait(0.5)
game.ReplicatedFirst.Parent = workspace
warn("[Game Loaded]")
local Checkpoint_Holder = workspace:WaitForChild("Checkpoints_Holder")
local Checkpoint_Notify = game.ReplicatedStorage:WaitForChild("Checkpoint_Notify")
local Checkpoint_Teleporter = game.ReplicatedStorage:WaitForChild("Teleport_Player_To_Current")
local Checkpoint_Get_Data = game.ReplicatedStorage:WaitForChild("Checkpoint_Data_Request")
local Checkpoint_Changed = game.ReplicatedStorage:WaitForChild("Checkpoint_Change")
local Tween_Service = game:GetService("TweenService")
local User_Input_Service = game:GetService("UserInputService")
local Sounds = game.ReplicatedStorage:WaitForChild("Sounds")
local Current_Checkpoint = 1
local Current_Checkpoint_Used = 1
repeat wait() until Checkpoint_Holder:WaitForChild("1")
if Current_Checkpoint == 1 then
game.Players.LocalPlayer.Character:MoveTo(Checkpoint_Holder[Current_Checkpoint].Position)
end
Checkpoint_Get_Data:FireServer()
local Player = game.Players.LocalPlayer
local Info_Displayer = script.Parent.Current:WaitForChild("Simple_Info")
local Current = script.Parent:WaitForChild("Current")
local Back_One = Current:WaitForChild("Back_One")
local Back_Ten = Current:WaitForChild("Back_Ten")
local Forward_One = Current:WaitForChild("Forward_One")
local Forward_Ten = Current:WaitForChild("Forward_Ten")
local Current_Stage_Displayer = Current:WaitForChild("Checkpoint_Current")
local Hovering
local function Color_Checkpoints()
for Index, Checkpoint in pairs(Checkpoint_Holder:GetChildren()) do
if tonumber(Checkpoint.Name) <= Current_Checkpoint_Used then
if tonumber(Checkpoint.Name) == Current_Checkpoint_Used then
Tween_Service:Create(Checkpoint, TweenInfo.new(0.5), {Color = Color3.fromRGB(75, 151, 75)}):Play()
else
Checkpoint.Color = Color3.fromRGB(75, 151, 75)
end
Checkpoint.Material = Enum.Material.Neon
Checkpoint.Numbering.Number.TextColor3 = Color3.fromRGB(255, 255, 255)
else
Checkpoint.Color = Color3.fromRGB(248, 248, 248)
Checkpoint.Material = Enum.Material.Plastic
Checkpoint.Numbering.Number.TextColor3 = Color3.fromRGB(0, 0, 0)
end
end
end
local function Get_Checkpoint(Number)
local Found
local Error
if Number > Current_Checkpoint then
Found = Checkpoint_Holder[Current_Checkpoint]
Error = "Can't go to stage "..Number..", sent to stage "..Current_Checkpoint
end
if Number < 1 then
Found = Checkpoint_Holder["1"]
Error = "Too low, sent to stage 1."
end
for Index, Checkpoint in pairs(Checkpoint_Holder:GetChildren()) do
if Checkpoint.Name == tostring(Number) and Number <= Current_Checkpoint then
Found = Checkpoint
end
end
if Found then
Current_Checkpoint_Used = tonumber(Found.Name)
return Found, Error
end
end
local function Display_Info(Text)
Info_Displayer.Visible = true
Info_Displayer.Text = Text
end
Color_Checkpoints()
User_Input_Service.InputBegan:Connect(function(Input)
if Input.KeyCode == Enum.KeyCode.R then
local Fetched_Stage = Get_Checkpoint(Current_Checkpoint_Used)
game.Players.LocalPlayer.Character:MoveTo(Fetched_Stage.Position)
end
end)
Checkpoint_Get_Data.OnClientEvent:Connect(function(Data)
Current_Checkpoint = Data
Current_Checkpoint_Used = Data
Color_Checkpoints()
game.Players.LocalPlayer.Character:MoveTo(Checkpoint_Holder:WaitForChild(Current_Checkpoint).Position)
for Index, Button in pairs(workspace.Buttons:GetChildren()) do
Button.Button.Color = Color3.fromRGB(255, 89, 89)
Button.Effected.Transparency = 1
Button.Effected.CanCollide = false
end
Display_Info("Successfully recieved data!")
Info_Displayer.TextColor3 = Color3.fromRGB(85, 255, 127)
wait(1)
Info_Displayer.Visible = false
end)
for Index, Checkpoint in pairs(Checkpoint_Holder:GetChildren()) do
Checkpoint.Numbering.Number.Text = Checkpoint.Name
end
Checkpoint_Notify.OnClientEvent:Connect(function(Checkpoint)
if Current_Checkpoint ~= tonumber(Checkpoint.Name) and Current_Checkpoint < tonumber(Checkpoint.Name) then
Current_Checkpoint = tonumber(Checkpoint.Name)
Current_Checkpoint_Used = Current_Checkpoint
Current_Stage_Displayer.Text = Current_Checkpoint_Used
Color_Checkpoints()
Sounds.Checkpoint:Play()
Checkpoint_Notify:FireServer(Current_Checkpoint)
Checkpoint_Changed:Fire(Current_Checkpoint_Used)
elseif Current_Checkpoint_Used < tonumber(Checkpoint.Name) then
Current_Checkpoint_Used = tonumber(Checkpoint.Name)
Current_Stage_Displayer.Text = Current_Checkpoint_Used
Color_Checkpoints()
Checkpoint_Changed:Fire(Current_Checkpoint_Used)
Sounds.Checkpoint:Play()
end
end)
--[ [] ] BUTTON WORKING [ [] ]--
for Index, Button in pairs(Current:GetChildren()) do
if Button:IsA("TextButton") then
Button.MouseEnter:Connect(function()
if Hovering ~= Button then
Hovering = Button
Info_Displayer.TextColor3 = Color3.fromRGB(255, 255, 255)
if Button == Back_One then
Display_Info("Go back 1 stage.")
Button.UIStroke.Color = Color3.fromRGB(255, 255, 255)
elseif Button == Back_Ten then
Display_Info("Go back 10 stages.")
Button.UIStroke.Color = Color3.fromRGB(255, 255, 255)
elseif Button == Forward_One then
Display_Info("Go forward 1 stage.")
Button.UIStroke.Color = Color3.fromRGB(255, 255, 255)
elseif Button == Forward_Ten then
Display_Info("Go forward 10 stages.")
Button.UIStroke.Color = Color3.fromRGB(255, 255, 255)
elseif Button == Current_Stage_Displayer then
Display_Info("Current stage.")
Button.UIStroke.Color = Color3.fromRGB(255, 255, 255)
end
end
end)
Button.MouseLeave:Connect(function()
Button.UIStroke.Color = Color3.fromRGB(0, 0, 0)
if Hovering == Button then
Hovering = nil
Info_Displayer.Visible = false
end
end)
Button.MouseButton1Up:Connect(function()
local Fetched_Stage, Error
if Button == Back_One then
Fetched_Stage, Error = Get_Checkpoint(Current_Checkpoint_Used - 1)
elseif Button == Back_Ten then
Fetched_Stage, Error = Get_Checkpoint(Current_Checkpoint_Used - 10)
elseif Button == Forward_One then
Fetched_Stage, Error = Get_Checkpoint(Current_Checkpoint_Used + 1)
elseif Button == Forward_Ten then
Fetched_Stage, Error = Get_Checkpoint(Current_Checkpoint_Used + 10)
end
if Fetched_Stage then
Current_Stage_Displayer.Text = Current_Checkpoint_Used
game.Players.LocalPlayer.Character:MoveTo(Fetched_Stage.Position)
for Index, Button in pairs(workspace.Buttons:GetChildren()) do
Button.Button.Color = Color3.fromRGB(255, 89, 89)
Button.Effected.Transparency = 1
Button.Effected.CanCollide = false
end
Checkpoint_Changed:Fire(Current_Checkpoint_Used)
Color_Checkpoints()
if Error == nil then
Display_Info("Successful!")
Info_Displayer.TextColor3 = Color3.fromRGB(85, 255, 127)
else
Display_Info(Error)
Info_Displayer.TextColor3 = Color3.fromRGB(255, 0, 0)
end
end
end)
end
end
remove the 0.5 wait im pretty sure its messing it up
No, I accidentally tried changing the parent of replicatedfirst itself instead of the folder . It works now!
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.