I have this block of code that checks if a value from the DataStoreService is true, and then gives the player an item.
local torch = game.ServerStorage.Torch local function onAdd(Player) Player.CharacterAdded:connect(function() local data = Player:WaitForChild("data") if data then print("Data folder located") local hasTorch = data:WaitForChild("hasTorch") if hasTorch then print("hasTorch found") wait(5) if hasTorch.Value then local newTorch = torch:Clone() newTorch.Parent = Player.Backpack else warn("hasTorch failed") end end end end) end game.Players.PlayerAdded:Connect(onAdd)
Is there a better way to wait for hasTorch to have a value? Without the wait it returns the warn statement and ends there.
Closed as Primarily Opinion-Based by User#19524
This question has been closed because it is a discussion about a topic focused on diverse opinions, which isn't a good fit for our Q&A format.
Why was this question closed?