Map not loading?

Hello devs!

I’m trying to create a Dummy Crash Testing game but the experiments doesn’t wan’t to work.

Output:

ReplicatedStorage.ExperimentLoader:10: invalid argument #2 (string expected, got table)

Module:

local Maps = game.ReplicatedStorage.Experiments

local module = {}

module.LoadExperiment = function(map)
	local ExistentExperiment = game.Workspace:FindFirstChild("ExperimentCurrent")
	if ExistentExperiment then
		ExistentExperiment:Destroy()
	end
	local Experiment = Maps[map]:Clone()
	Experiment.Parent = workspace
	Experiment.Name = "ExperimentCurrent"
end

return module

I have tried using remoteevents but it broke with the same error.

That means map is table, not a string.

local mod = require(path to mod)

-- Errors, we gave it a table but [] needs a string. It's like saying Maps[{table}]
mod.LoadExperiment({"Map1", "Map2"})

-- Works fine, it's like saying Maps["Map1"]
mod.LoadExperiment("Map1")

Can we see the script using the module and calling LoadExperiment?

Sure:

script.Parent.MouseButton1Click:Connect(function()
	require(game.ReplicatedStorage.ExperimentLoader):LoadExperiment("Ballhit")
end)

the map name is ballhit because i’m not creative so i ended up with that

Can you do print(typeof(map)) in your module? If it’s a string, then something is wrong with the line itself.

Actually, The map is a model.

characterlimit

Screen Shot 2021-06-12 at 4.20.07 PM

You are passing a string, I was asking to see if it remained the same inside the module.

It returned table

image

Hmmm, you are doing :LoadExperiment("Ballhit").

Maybe try just doing .LoadExperiment("Ballhit")

1 Like

Oh it worked! Thank you so much!

1 Like