Hi! I have a datastore in my game but I want to make it that it fires an event when it finishes loading so a few other scripts doesn’t start before the data loads. Here is what I have for now:
-- Datastore script hidden above.
print("loaded")
local loadedData = Instance.new("BindableEvent")
loadedData.Name = "LoadedData"
loadedData.Parent = game:GetService("ServerScriptService")
loadedData:Fire()
print("fired")
And here is my script that I don’t want to run before the data loads:
local loadedData = game:GetService("ServerScriptService"):WaitForChild("LoadedData")
game.Players.PlayerAdded:Connect(function(player)
loadedData.Event:Wait()
print("Script waited successfully")
-- Rest of the script hidden
end)
I only get "loaded"
and "fired"
in my output but not “script waited successfully”. I don’t understand what is wrong with my script, please help.