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

How would I make it so that if something in pcall fails the other fails?

Asked by 4 years ago

So what im trying to do is

If One GetAsync in pcall either first or next line if one of them fails Both of them just don't run

or how would I check if GetAsync was succesful so that I can run getasync safely

Module


local DataStore1 = game:GetService("DataStoreService"):GetDataStore('DataStore1') local DataStore2 = game:GetService("DataStoreService"):GetDataStore('DataStore2') local module = {} function module.GetData1(Player) pcall(function() DataStore1:GetAsync(Player.UserId) end) end function module.GetData2(Player) pcall(function() DataStore1:GetAsync(Player.UserId) end) end return module

Script

local Mod = require(game.Workspace.ModuleScript)

game.Players.PlayerAdded:Connect(function(plr)

local S,E = pcall(function()
    Mod.GetData1(plr) -- If this fails I want GetData2 to not run
    Mod.GetData2(plr)-- If This fails I want GetData2 to not run 

end)


end)

Answer this question