Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

If statement not detecting map name?

Asked by 6 years ago

Hi, I'm currently having a problem where my 'if statement' doesn't detect the name of the map and instead just prints the error.

I'm relatively new to Lua (have been working on it for a couple of weeks now) and might just have overlooked something very simple here.

I would very much appreciate if anyone could fix this as it looks like it should work to me:

(my function MovePlayers does work as I've tested it outside of the if statement so that's not the issue)

local num = math.random(1,2)
local map = game.ServerStorage:WaitForChild("Map" ..num)
map:clone().Parent = game.Workspace

print(map)

if map == ("Map1") then
    MovePlayers(Vector3.new(1129.8, 0.5, -6.1), Vector3.new(928.2, 0.5, 183.7), Vector3.new(784.1, 0.5, -86.3))
elseif map == ("Map2") then
    MovePlayers(Vector3.new(1129.8, 0.5, -6.1), Vector3.new(928.2, 0.5, 183.7), Vector3.new(784.1, 0.5, -86.3))
else
    error("No map found")
end

Thanks for any help offered!

0
yoo im not sure but ttry if map.Map1 == nil then tacotown2 119 — 6y
0
Can you show us the error. Mr_Unlucky 1085 — 6y
0
There only error is the one I wrote in the else statement, if I remove that it just runs the script normally without teleporting the players, there's no crash or anything RIBBENTROPP 45 — 6y

Answer this question