local DataStoreService = game:GetService("DataStoreService")
local myDataStore = DataStoreService:GetDataStore("myDataStore")
game.Players.PlayerAdded:Connect(function(player)
local leaderstats = Instance.new("Folder")
leaderstats.Name = "leaderstats"
leaderstats.Parent = player
local Time = Instance.new("IntValue")
Time.Name = "Time"
Time.Parent = leaderstats
local Height = Instance.new("IntValue")
Height.Name = "Height"
Height.Parent = leaderstats
local char = player.CharacterAdded:Wait()
local playerUserId = "Player"..player.UserId
local data
local success, errormessage = pcall(function()
data = myDataStore:GetAsync(playerUserId)
end)
if success then
Time.Value = data
end
while wait(60) do
player.leaderstats.Time.Value = player.leaderstats.Time.Value + 1
end
while task.wait() do
Height.Value = char:GetPivot().Position.Y
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerUserId = "Player"..player.UserId
local data = player.leaderstats.Time.Value
myDataStore:SetAsync(playerUserId, data)
end)
#the height doesn't work
1 messages · Page 1 of 1 (latest)
It's not working BC u got while wait loop
Over it
Making code never go till your height loop
Task.spawn it
And plz use like while task.wait(60) and player and player:FindFirstChild("leaderstats')
still nothing
** You are now Level 2! **
like this?
man idk much about coding dont expect much from me
task.spawn(function()
Code
end)
And do that on first loop
Or move height one to be over leaderstats one and use it on height
like this?
Yes but u need loop
Task spawn makes it a background task
Aka code doesn't wait for it to be done
It just lets it run and goes to executing next line
like this?
This
Just put the while true do and rest
Inside of code
?
U don't know coding do u
thats what im saying
Literally take this code, and where u got while wait(60) make it task.wait and just wrap it around task.spawn like I told
.