Hello, I am working on an obby game and I used a free model for the checkpoints, now I’m starting to wonder if I should replace it… The problem is is that there are two errors in the output breaking parts of the functionality. Heres a picture of the errors:
Anyone know whats wrong? Here are the scripts:
Server script in ServerScriptService
local RS = game:GetService("ReplicatedStorage")
repeat wait() until script.Main ~= nil
local main = require(script:WaitForChild("Main")) --Error here
function recived(plr, direction)
if direction == "up" then
main.up(plr, direction)
elseif direction == "down" then
main.down(plr, direction)
elseif direction == "up1" then
main.up10(plr, direction)
elseif direction == "down10" then
main.down10(plr, direction)
elseif plr.leaderstats.Stage.Value > main.TOTAL_STAGES_IN_GAME then
print("Player is in an older version of the game!")
end
end
RS.StageTransfer.OnServerEvent:Connect(recived)
Module script inside the Server script:
local trasferHandler = {}
local TOTAL_STAGES_IN_GAME = 0
for _, stage in pairs(workspace.Checkpoints:GetChildren()) do
if tonumber(stage.Name) > TOTAL_STAGES_IN_GAME then --Error here
TOTAL_STAGES_IN_GAME = tonumber(stage.Name)
end
end
function trasferHandler.up(plr, direction)
local tpStage = plr.TeleportedStage
if tpStage.Value < plr.leaderstats.Stage.Value then
tpStage.Value += 1
plr.Character.HumanoidRootPart.CFrame = workspace.Checkpoints[plr.TeleportedStage.Value].CFrame + Vector3.new(0,3.25,0)
elseif tpStage.Value == plr.leaderstats.Stage.Value then
tpStage.Value = 0
plr.Character.HumanoidRootPart.CFrame = workspace.Checkpoints["0"].CFrame + Vector3.new(0,3.25,0)
end
end
function trasferHandler.down(plr, direction)
local tpStage = plr.TeleportedStage
if tpStage.Value > 0 then
tpStage.Value -= 1
plr.Character.HumanoidRootPart.CFrame = workspace.Checkpoints[tpStage.Value].CFrame + Vector3.new(0,3.25,0)
elseif tpStage.Value == 0 then
tpStage.Value = plr.leaderstats.Stage.Value
plr.Character.HumanoidRootPart.CFrame = workspace.Checkpoints[plr.leaderstats.Stage.Value].CFrame + Vector3.new(0,3.25,0)
end
end
function trasferHandler.up10(plr, direction)
local tpStage = plr.TeleportedStage
if tpStage.Value + 9 < plr.leaderstats.Stage.Value then
tpStage.Value += 10
plr.Character.HumanoidRootPart.CFrame = workspace.Checkpoints[plr.TeleportedStage.Value].CFrame + Vector3.new(0,3.25,0)
elseif tpStage.Value == plr.leaderstats.Stage.Value then
tpStage.Value = 0
plr.Character.HumanoidRootPart.CFrame = workspace.Checkpoints["0"].CFrame + Vector3.new(0,3.25,0)
end
end
function trasferHandler.down10(plr, direction)
local tpStage = plr.TeleportedStage
if tpStage.Value > 9 then
tpStage.Value -= 10
plr.Character.HumanoidRootPart.CFrame = workspace.Checkpoints[tpStage.Value].CFrame + Vector3.new(0,3.25,0)
elseif tpStage.Value == 0 then
tpStage.Value = plr.leaderstats.Stage.Value
plr.Character.HumanoidRootPart.CFrame = workspace.Checkpoints[plr.leaderstats.Stage.Value].CFrame + Vector3.new(0,3.25,0)
end
end
return trasferHandler