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

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

Asked by 5 years ago
Edited 5 years ago

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
0
is it a localscript or script Vain_p 78 — 5y
0
5_zn I posted a fix for you Ziffixture 6913 — 5y
0
Could you explain more? Give me the details about MapLoader and what is is it whatever your checking Ziffixture 6913 — 5y
0
its a local script TheExtraDip 19 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago
if game.ReplicatedStorage.MapLoader.Value == 1 then
print("Test")
end
2
use game:GetService("ReplicatedStorage") also add your waitforchilds Imperialy 149 — 5y
0
You need to explain the script. yHasteeD 1819 — 5y
0
this is my exact script but the number 1 instead of map 1 TheExtraDip 19 — 5y
Ad
Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago
Edited 5 years ago

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?

0
your if statement doesnt make sense at all and will error Gey4Jesus69 2705 — 5y
0
Your if statement would have syntax error. Correction: `if ((MapLoader > 0) and (MapLoader < 2)){...}` AbstractionsReality 98 — 5y
0
Also congratulations on 100 rep. AbstractionsReality 98 — 5y
0
Thanks, I also know that, I was just trying something because why not?;) I’ll fix, thanks guys Ziffixture 6913 — 5y

Answer this question