#the height doesn't work

1 messages · Page 1 of 1 (latest)

haughty tree
#
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)
finite flicker
#

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')

haughty tree
empty girderBOT
#

studio** You are now Level 2! **studio

finite flicker
#

U can ss

#

Am on phone

haughty tree
finite flicker
#

What the fuck

#

Did u just do

#

No

#

Bruh

haughty tree
#

man idk much about coding dont expect much from me

finite flicker
#

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

haughty tree
finite flicker
#

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

haughty tree
finite flicker
#

Literally keep your code

finite flicker
#

Just put the while true do and rest

Inside of code

haughty tree
finite flicker
#

U don't know coding do u

haughty tree
#

thats what im saying

finite flicker
finite flicker
haughty tree
#

now it works