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
As I see it, your script is flawed that, even if we do give an answer... it will not work with the rest of your coding... as such, i suggest you try to make it so that everything is coherent... for example:
The map is still in ServerStorage
, to move it you should use:
local mapholder = Instance.new("Model", game.Workspace) mapholder.Name = "CurrentMap" game.ServerStorage.Maps.Arena --[[ error ]]
Your map will now error because the map has a NumberValue
in a line of code that has a String
, as such you will need to use FindFirstChild()
local mapholder = Instance.new("Model", game.Workspace) mapholder.Name = "CurrentMap" local mapa = game.ServerStorage.Maps:FindFirstChild("Arena1") mapa.Parent = mapholder
I could keep going on, but I will instead recommend you to some ROBLOX wiki pages that you should learn:
http://wiki.roblox.com/index.php?title=Loops
http://wiki.roblox.com/index.php?title=Function_dump/Basic_functions&redirect=no#pairs
http://wiki.roblox.com/index.php?title=API:Class/Instance/FindFirstChild
After you have done this, you should start from scratch, and attempt to create a smooth code.. if you still cannot do this, pm me on roblox (Username: Taryo)
~ Taryo
Edit:
Removed CFrame
and Vector3
from recommended list, you can still view them here:
http://wiki.roblox.com/index.php?title=CFrame http://wiki.roblox.com/index.php?title=Vector3