Gamemode Map System

I am making a map gamemode system where if the map is named a certain thing then the gamemode is set to a certain one.

if chosenmap.Value == “Swampy Lands” or “Low-Poly City” or “Library” then
gamemode.Value = “Solo”
elseif chosenmap.Value == “Dredge” or “Imagine Beach” or “Vacation” then
gamemode.Value = “Teams”
else
gamemode.Value = “”
print(“Unkown map chosen can’t decide gamemode.”)
end
print(chosenmap.Value)
print(gamemode.Value)

It does print the acrorect map but when it prints gamemode its always stuck on solo anyone know why? When the map is on teams and teams should be set its still solo

because you setted it to solo ggg

no mate when the other map is chosen it should be set to teams but its always solo

Can you send me the full script?

its like 400 lines but the map is set correctly. For example, if dredge is picked it does print dredge but game mode is still printed solo

Needs to change to

if chosenmap.Value == “Swampy Lands” or chosenmap.Value == “Low-Poly City” or chosenmap.Value == “Library” then

Since the other strings always evaluate to true

ah makes sense thanks! ill try it out rn

Now it prints the else

print(“Unkown map chosen can’t decide gamemode.”)

if chosenmap.Value == "Swampy Lands" or chosenmap.Value == "Low-Poly City" or chosenmap == "Libary" then
		gamemode.Value = "Solo"
	elseif chosenmap.Value == "Dredge" or chosenmap.Value == "Imagine Beach" or chosenmap.Value == "Vacation" then
		gamemode.Value = "Teams"
	else
		gamemode.Value = ""
		print("Unkown map chosen can't decide gamemode.")
	end
	print(chosenmap.Value)
	print(gamemode.Value)

Can you share the outputs of the print statements? Also you’re not checking chosenmap.Value for the Library

wdym for the libary? and yes here is the output:

image

ah yes ill fix the libary.value but thats the output above

hello? are you still here able to help

try removing the else statement, i believe thats where your problem lies. plus no reason to have it.

local soloMaps = {"Swampy Lands", "Low-Poly City", "Library"}
local teamMaps = {"Dredge", "Imagine Beach", "Vacation"}

if table.find(soloMaps, chosenmap.Value) then
	gamemode.Value = "Solo"
elseif table.find(teamMaps, chosenmap.Value) then
	gamemode.Value = "Teams"
else
	gamemode.Value = ""
end

print(chosenmap.Value)
print(gamemode.Value)

not working i tried this way too

Then chosenmap.Value isn’t matching the string values being checked in the script. Is chosenmap an ObjectValue instance? Because if it is then this won’t work.

Here is the code that sets it

local chosenmap = winner.Value
	textstring.Value = textphrase2
	if not winner.Value then
		print("Something went wrong!")
		break
	end

	local map = chosenmap.Value
	clonemap = map:Clone()
	print("Getting map...")
	wait(1)
	print("Getting map spawn...")

	if clonemap.Spawns.SpawnLocation then
		print("Success!")
	else
		print("Task failed successfully")
		wait()
		print("Restarting...")
		clonemap:Destroy()
		break
	end
	
	if table.find(soloMaps, chosenmap.Value) then
		gamemode.Value = "Solo"
	elseif table.find(teamMaps, chosenmap.Value) then
		gamemode.Value = "Teams"
	else
		gamemode.Value = ""
	end
	print(chosenmap.Value)
	print(gamemode.Value)

Yeah, so chosenmap is an ObjectValue instance (its value, if one exists, is a reference to some object, in this case a map).

if table.find(soloMaps, chosenmap.Value.Name) then
	gamemode.Value = "Solo"
elseif table.find(teamMaps, chosenmap.Value.Name) then
	gamemode.Value = "Teams"
else
	gamemode.Value = ""
end

You’ll need the value of the “Name” property of the instance (which is a string value).

1 Like

ah yes that makes sense its an object but we are trying to verify if its the same name not same object! Thanks so much!