Hi! I want to know why the if code doesn’t end properly.
The ServerScript file in the ServerScript Service contains the code below.
local s, e = pcall(function()
module.plrData = dataStore:GetAsync("gamePlace01")
end)
if s then
print("GetAsync Success")
print("GetAsync Data")
print(module.plrData)
else
print("GetAsync Error")
print(e)
end
print("if end!!")
I wanted to run the Players.PlayerAdded code behind this code, but I couldn’t. I checked with print() where the code stops, and if s then performs all the code well, but print(“if end!!”) does not run. What’s the problem?
==========한국어(Korean)==========
안녕하세요! if문이 왜 제대로 종료되지 않는지 알고싶습니다.
ServerScriptService에 있는 ServerScript 파일에는 아래 코드가 있습니다.
local s, e = pcall(function()
module.plrData = dataStore:GetAsync("gamePlace01")
end)
if s then
print("GetAsync Success")
print("GetAsync Data")
print(module.plrData)
else
print("GetAsync Error")
print(e)
end
print("if end!!")
위 코드의 뒤에 있는 Players.PlayerAdded를 실행하고 싶었지만 실행할 수 없었습니다. 코드가 어디에서 멈추는지 print()로 확인해본 결과 if s then 에서 모든 코드를 잘 수행하지만 print(“if end!!”)가 실행되지 않습니다. 무엇이 문제일까요?
Ohh, I read it wrong I’m so sorry. To run print(“if end!!”) if it is true then use the following code.
local s, e = pcall(function()
module.plrData = dataStore:GetAsync("gamePlace01")
end)
if s then
-- If true then perform this code
print("GetAsync Success")
print("GetAsync Data")
print(module.plrData)
print("if end!!")
else
-- If error do this
print("GetAsync Error")
print(e)
end
If the issue persists then make sure that the datastore “gamePlace01” and “module.plrData” exists.
You just put the print in the wrong area, also you cannot perform “A + 5” (but it is awesome for simulating errors!).
Restarting the computer didn’t solve it, and the problem suddenly went away even though I didn’t modify the code. The console log wasn’t even covered by the scroll, but it’s strange.