Bug with Line Runner Template

I saw this error fixed in one of the other forums but I can’t get how.

The error I get in the console:

ServerScriptService.Server_Main:60: End is not a valid member of Model “ReplicatedStorage.PathModules.Path"

Now I thought it was supposed to add a folder and then the end part. I tested later but I was still getting this error.

Thanks for reading.

Could you show me the explorer and the script where the error occurs?

Image:

Line 60 (placed note):




local path = nil
coroutine.wrap(function() path = require(script.PathCreator) end)()

-- Handle remote functions/events
function runStarting(player)
	if player.Character then
		if player.Character:FindFirstChild("FastStartScript") then
			player.Character.FastStartScript.Disabled = false
		end
	end
end
game.ReplicatedStorage.RemoteEvents.RunStarting.OnServerEvent:connect(runStarting)

local behaviourModules = {}

coroutine.wrap(function()
	for _, behaviourScript in ipairs(script.Behaviours:GetChildren()) do
		local success, errMessage = pcall(function() 
			behaviourModules[behaviourScript.Name] = require(behaviourScript) 
		end)
		if not success then
			warn("Failed to load module" ..behaviourScript.Name.. ".\n" ..errMessage)
		end
	end
end)()

function executeBehaviour(player, character, brickTouched, behaviourName)
	if behaviourModules[behaviourName] ~= nil then
		behaviourModules[behaviourName]:ExecuteBehaviour(brickTouched, character)
	end
end
game.ReplicatedStorage.RemoteEvents.ExecuteBehaviour.OnServerEvent:connect(executeBehaviour)

-- Initialization
local lastActivePath = {}

if game.Workspace:FindFirstChild("BasePlate") then
	game.Workspace.BasePlate:Destroy()
end

local tracksModel = Instance.new("Model")
tracksModel.Name = "Tracks"
tracksModel.Parent = game.Workspace

function packagePathModels()
	local pathPackager = require(script.PathPackager) 
	while true do
		local pathBase = game.Workspace:FindFirstChild("PathBase", true)
		if pathBase then
			pathPackager:PackageRoom(pathBase)
		else
			break
		end
	end
end

 --This line
coroutine.wrap(function() packagePathModels() end)()

-- Leaderboard
function loadLeaderstats(player)
	local stats = Instance.new("IntValue")
	stats.Name = "leaderstats"

	local highScore = Instance.new("IntValue")
	highScore.Name = "High Score"
	highScore.Parent = stats
	highScore.Value = 0

	local currentScore = Instance.new("IntValue")
	currentScore.Name = "Score"
	currentScore.Parent = stats
	
	stats.Parent = player
end

function initialiseRunStats(player)
	if player:FindFirstChild("RunStats") then
		player.RunStats.Distance.Value = 0
		player.RunStats.CoinsCollected.Value = 0
	end
end

function showResults(player)
	local resultsGUI = game.ServerStorage.GUIs.PostRunGUI:Clone()
	resultsGUI.Frame.DistanceValue.Text = player.RunStats.Distance.Value
	resultsGUI.Frame.CoinsValue.Text = player.RunStats.CoinsCollected.Value
	resultsGUI.Frame.ScoreValue.Text = player.leaderstats.Score.Value

	resultsGUI.Parent = player.PlayerGui
	return resultsGUI
end

function initialiseNewRun(player, delayTime, charExpected, showLastResults)
	if not path then
		while not path do
			wait()
		end
	end

	local lastResultsGUI = nil
	if showLastResults then
		lastResultsGUI = showResults(player)
	end

	if delayTime ~= 0 then
		wait(delayTime)
	end	
	
	if lastResultsGUI ~= nil then
		lastResultsGUI:Destroy()
	end

	if player and player.Parent then
		-- charExpected is needed to avoid calling LoadCharacter on players leaving the game
		if player.Character or charExpected == false then
			player:LoadCharacter()
			
			initialiseRunStats(player)
			
			local playersPath = path()
			lastActivePath[player.Name] = playersPath
			playersPath:init(player.Name)
		end
	end
end

function setUpPostRunStats(player)
	local folder = Instance.new("Folder")
	folder.Name = "RunStats"
	folder.Parent = player
	local currentDistance = Instance.new("IntValue")
	currentDistance.Name = "Distance"
	currentDistance.Value = 0
	currentDistance.Parent = folder
	local coinsCollected = Instance.new("IntValue")
	coinsCollected.Name = "CoinsCollected"
	coinsCollected.Value = 0
	coinsCollected.Parent = folder
end

function onPlayerEntered(player)	
	player.CharacterAdded:connect(function(character)
		local humanoid = character:WaitForChild("Humanoid")
		if humanoid then
			humanoid.Died:connect(function()
				initialiseNewRun(player, 4, true, true)
			end)
		end
	end)
	
	-- Initial loading
	loadLeaderstats(player)	
	setUpPostRunStats(player)
	
	-- Start game
	initialiseNewRun(player, 0, false, false)
end
game.Players.PlayerAdded:connect(onPlayerEntered)

function onPlayerRemoving(player)	
	local track = game.Workspace.Tracks:FindFirstChild(player.Name)
	if track ~= nil then
		track:Destroy()
	end
end
game.Players.PlayerRemoving:connect(onPlayerRemoving)

for _, player in pairs(game.Players:GetChildren()) do
	onPlayerEntered(player)
end

One thing, when you say “if player.Character” are you check if the player exists once, or are waiting for it? because if you’re waiting for it, there’s a chance it won’t exist, and that script won’t be executed in the runStarting() function.

Not my script it’s from Roblox template. Error was there from beggining. Should I remove that char wait stuff

Wait, is the template with the sideview coin collecter running game?

1 Like

Put a WaitForChild() when trying to access Path.End where you’re trying to access it. Path:WaitForChild("End"). It may not have been replicated yet.

Well now I just fly down and die

robloxapp-20221202-1949433.wmv (482.0 KB)

You ment this?

It looks like the error is happening the function, but it’s actually probably occurring in the script.PathPackages folder. look in there for any references of ".End.

Also, the script is kind of entirely stupid, because they’re doing everything in a coroutine, so some thread may have not finished yet, but another thread is trying to reference something supposed to be already created in the other.

image

Yes, look into PathPackages, then find .End and then instead of indexing it, use a WaitForChild("End")

I can’t find it in this script or any else in ServerScriptService

Hm… could you send me the .rbxl file?

Line Runner.rbxl (221.4 KB)

There is alot going on in that file. It’s hard to read. I suggest you make your own line runner if that’s what you’re trying to do, because most likely this one is outdated, and it’s just a template anyways.

1 Like