Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Why wont my if statement read my string value? [answered]

NEW VERSION: https://scriptinghelpers.org/questions/73462/why-wont-my-if-statement-read-my-string-value-answered

Why wont this work

if game.ReplicatedStorage.MapLoader.Value == "map1" then

	print("Test")

end

4 comments

0

is it a localscript or script

0

5_zn I posted a fix for you

0

Could you explain more? Give me the details about MapLoader and what is is it whatever your checking

0

its a local script

2 answers

if game.ReplicatedStorage.MapLoader.Value == 1 then
print("Test")
end

3 comments

2

use game:GetService("ReplicatedStorage") also add your waitforchilds

0

You need to explain the script.

0

this is my exact script but the number 1 instead of map 1

Sometimes it’s best if the if statement is less direct and more variable, although it works both ways. Try this anyway

local ReplicatedStorage = game:GetService(“ReplicatedStorage”) --//more efficient method of indexing
local MapLoader = ReplicatedStorage:WaitForChild(“MapLoader”).Value --//helps to yield so the script doesn’t break or check f something is ‘nil’

if (MapLoader == 1) then
   print(“Okay”)
end

There are also things that could cause the issue, for instance, check if you accidentally disabled the script?

4 comments

0

your if statement doesnt make sense at all and will error

0

Your if statement would have syntax error. Correction: if ((MapLoader > 0) and (MapLoader < 2)){...}

0

Also congratulations on 100 rep.

0

Thanks, I also know that, I was just trying something because why not?;) I’ll fix, thanks guys

This discussion is preserved as it was. New answers, comments, and votes are closed.