A showcase when the error is happening (https://i.gyazo.com/41979731fb5fed1c49fc634faa13c947.mp4) . It's supposed to become dark and teleport to the border and the dark should dissapear but instead it becomes dark and never telports? What's the error?

    local playerfound = false

  

function CreateRegion3FromPart(Part)

return Region3.new(Part.Position-(Part.Size/2),Part.Position+(Part.Size/2))

end

  

function GetPlayersInPart(part)

local region = CreateRegion3FromPart(part)

local partsInRegion = workspace:FindPartsInRegion3(region,nil,math.huge)

local Players = {}

for i,Part in pairs(partsInRegion) do

local player = game.Players:GetPlayerFromCharacter(Part.Parent)

if player then

for i, v in pairs(Players) do

if Players[i].Name == player.Name then

playerfound = true

end

end

if playerfound == false then

table.insert(Players,player)

end

playerfound = false

end

end

  

for i, v in pairs(Players) do

if Players[i].Character:FindFirstChild("Humanoid").SeatPart ~= nil and v.Course.Value == part.Course.Value and not v.PlayerGui:FindFirstChild("Dark") then

local Dark = script.Dark:Clone()

Dark.Parent = v.PlayerGui

wait(.1)

for i = 1,100 do

Dark.Frame.BackgroundTransparency = Dark.Frame.BackgroundTransparency - 0.01

wait(.02)

end

Players[i].Character:FindFirstChild("Humanoid").SeatPart.Parent:Destroy()

wait(.1)

Players[i].Character:FindFirstChild("UpperTorso").CFrame = workspace.Scaffoldings:FindFirstChild(v.Course.Value).CFrame + Vector3.new(0,5,0)

v.Course.Value = 0

for i = 1,100 do

Dark.Frame.BackgroundTransparency = Dark.Frame.BackgroundTransparency + 0.01

wait(.02)

end

Dark:Destroy()

else

end

end

return Players

end

  

while wait(0.1) do

for i,v in pairs(game.Workspace.BoatRemoves:GetChildren()) do

GetPlayersInPart(v)

end

end

This is the error that's printed "ServerScriptService.BoatTouch:41: attempt to index a nil value"

The error forwards to this line Players[i].Character:FindFirstChild("UpperTorso").CFrame = workspace.Scaffoldings:FindFirstChild(v.Course.Value).CFrame + Vector3.new(0,5,0)

4 comments

0

No, do not offer money for solutions here

0

And it would be nice if you told us what line the error was happening on. I don't know about anyone else, but I am not going to sift through 100 lines of code with missing indentation for a problem that may or may not cause your error.

0

Read the rules before asking another question, and remove that last sentence from your question. Rules: https://scriptinghelpers.org/help/community-guidelines

0

@steamG0D ServerScriptService.BoatTouch:41: attempt to index a nil value