Hello!

In my game I teleport a player to another place with an array/table/list of data. But when I teleport the player to said place, it acknowledges the information, but does not doesn't do the rest of the script because of an error, but more on that later. Here are snippets from the main scripts.

SELECTING INFO TO PLACE IN ARRAY

local states = {"abandoned", "in construction", "active"}
local state = states[math.random(1, #states)]
script.Parent.Status.Value = state

TELEPORTATION

        TS:TeleportToPrivateServer(4547708279, code, {player}, "SpawnLocation", {script.Parent.Parent.Name, script.Parent.Parent.Status.Value})

RECEIVING DATA (Status)

--variables


data = game:GetService("TeleportService"):GetLocalPlayerTeleportData()

local status = data[2]

--local statuses = 'abandoned'--{'abandoned','active','in construction'}
--local status = statuses--[math.random(1,3)]

print("This Celestial Base's status is "..status)

--flooring

if status == 'abandoned' then
	workspace.SKyModel.Script:Destroy()
	local children = workspace.Parts:GetChildren("floor")
	for i, child in ipairs(children) do
		child.Material = Enum.Material.CorrodedMetal
	end
	
	workspace.p1.PointLight.Enabled = false
	workspace.p3.PointLight.Enabled = false
	workspace.p7.PointLight.Enabled = false
	workspace.p5.Flicker.Disabled = false
	workspace.p2.Flicker.Disabled = false
	workspace.p8.Flicker.Disabled = false
	
	workspace.Glass1.Reflectance = 2
	workspace.Glass2.Reflectance = 2
	
	workspace.Glass1.Color = Color3.new(241, 231, 199)
	workspace.Glass2.Color = Color3.new(241, 231, 199)
	
end

I test this and when I am teleported to the place, a text label gui with the data that has been brought over has the correct data, but the "if status == 'abandoned' then" section doesn't run because of an error. So I open the developer console in my game and see the error:

workspace.Status:6: attempt to index nil with number

Then I realized that the gui script was a LocalScript while this one was a Script so I tried changing it to a LocalScript but that didn't do anything either. In the dev console there was no error anymore, but still, nothing happened. Gah!

So basically one script is receiving data while the other isn't. This is either bizarre or I am greatly misunderstanding how to code this.

Sorry if this is a lot of information to comprehend, I feel the same way. Any help is greatly appreciated because my game depends on it!

TYSM

2 comments

0

Which script is receiving data?

0

Status, the bottom one.