Im trying to make a minigame that only have 1 map for now and its speed run. The problem is it keeps saying a nil value until I have no idea. So I need a help here. Here is the dev console : [I use a link because I can't put my screenshot here by using trello] https://trello.com/c/owZ7gkSZ/27-a-nil-value-problem-screenshot
And the script :
--start
local Player1 = game.Players.PlayerAdded:wait()
--variables
Map1 = game.ServerStorage.Maps.Arena1
NotificationBoard = game.Workspace.StatusBar.Text
TpEnabled = false
-- Scripts
--TpScript
--Reciver Vars
Spawn1o = 0
Spawn2o = 0
Spawn3o = 0
Spawn4o = 0
Spawn5o = 0
Spawn6o = 0
enabled = true
Reciver = game.Workspace.Spawn.Spawn1
--Main Tp Script
game.Workspace.TpSender.Touched:connect(function(part)
local hum = part.Parent:FindFirstChild("Humanoid")
if hum~=nil then
if TpEnabled == true then
if enabled == true then
enabled = false
local t = part.Parent:FindFirstChild("Torso")
local t2 = Reciver
t.CFrame = CFrame.new(t2.Position.x, t2.Position.y+4, t2.Position.z)
Spawn1o = Spawn1o +1
wait(1)
enabled = true
if Spawn1o == 4 then
Reciver = game.Workspace.Spawn.Spawn2
if Spawn2o == 4 then
Reciver = game.Workspace.Spawn.Spawn3
if Spawn3o == 4 then
Reciver = game.Workspace.Spawn.Spawn4
if Spawn4o == 4 then
Reciver = game.Workspace.Spawn.Spawn5
if Spawn5o == 4 then
Reciver = game.Workspace.Spawn.Spawn6
end
end
end
end
end
end
end
end
end)
--WinnerDetector
game.Workspace.WinnerDetector.Touched:connect(function(hit)
local Plr = game.Players:GetPlayerFromCharacter(hit.Parent)
game.ReplicatedStorage.Variables.WinnerFound.Value = true
game.ReplicatedStorage.Variables.Winner.Value = Plr.Name
hit.Parent.Humanoid.Health = 0
end)
--Gamemode Changer
while true do
wait(5)
Player1.PlayerGui.WinnerGui.TextBox.Text = ("Please Wait")
NotificationBoard.Value = ("Please Wait")
print("Wait60")
wait(60)
NotificationBoard.Value = ("Current Map : SpeedRun")
NotificationBoard.Value = ("Current Map : SpeedRun")
print("LoadMap")
wait(5)
NotificationBoard.Value = ("Loading...")
NotificationBoard.Value = ("Loading...")
wait(2)
Map1:clone().Parent = game.Workspace
Player1.PlayerGui.WinnerGui.TextBox.Text = ("Teleporting Players")
TpEnabled = true
NotificationBoard.Value = ("Game In Progress")
NotificationBoard.Value = ("Game In Progress")
Player1.PlayerGui.WinnerGui.TextBox.Text = ("Game In Progress")
if game.ReplicatedStorage.Variables.WinnerFound.Value == true then
game.ReplicatedStorage.Variables.WinnerFound.Value = false
game.Workspace.Map:destroy()
TpEnabled = false
Spawn1o = 0
Spawn2o = 0
Spawn3o = 0
Spawn4o = 0
Spawn5o = 0
Spawn6o = 0
NotificationBoard.Value = "Game Ended"
NotificationBoard.Value = "Game Ended"
Player1.PlayerGui.WinnerGui.TextBox.Text = "Winner :" ..game.ReplicatedStorage.Variables.Winner.Value
wait(10)
game.ReplicatedStorage.Variables.Winner.Value = "None"
Player1.PlayerGui.WinnerGui.TextBox.Text = "Winner :" ..game.ReplicatedStorage.Variables.Winner.Value
end
end

3 comments
Line 2 - It's not gonna work that way, You gotta bind a function to player added event
The problem is the line 61. See the dev console screenshot
Anyway thanks for that tips. Because I just noticed that line 2 is a bit weird and glitchy before I edit the script into the script you see now.