Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to wait until datastore finished loading?

Hello,

I have this script that is supposed to multiply the value of "SpeedLevel" (an int value) by 3 and add that to the player's WalkSpeed as soon as the player joins the game. The problem is that the datastore with the "SpeedLevel" is never done loading...

Here is my script, located in StarterScriptService.

game.Players.PlayerAdded:Connect(function(player)
	local Character = player.Character or player.CharacterAdded:Wait()
	local SpeedLevel = player.InfoFolder.SpeedLevel
	local WalkSpeed = Character.Humanoid.WalkSpeed
	
	print(SpeedLevel.Value) -- Prints 0, but if the datastore was fully loaded it would print 5

	
	WalkSpeed = WalkSpeed + (SpeedLevel.Value*3)
end)

Thank you!

1 answer

✓ Accepted answer

this is the premium benefits code for people to get more walkspeed, max health, and jump power. this code only works for premium people but as you can see EnumMembershipType.None so now people with no member ship can use it.

local Players = game:GetService("Players") Players.PlayerAdded:connect(function(player)

if player.MembershipType == Enum.MembershipType.None then
	player.CharacterAdded:connect(function(char)
		local humanoid = char:findFirstChild ("Humanoid")
		if humanoid then
			humanoid.MaxHealth = 1000
			humanoid.Health = humanoid.MaxHealth
			humanoid.WalkSpeed = 200
			humanoid.JumpPower = 100
			local confetti = Instance.new("Sparkles", char:findFirstChild("HumanoidRootPart"))
		end
	end)
end	

end)

This discussion is preserved as it was. New answers, comments, and votes are closed.