Sometimes the text won’t update until a player dies, not sure why, i don’t think the data loads quick enough but idk how to fix
local DataStoreModule = require(game.ServerStorage.DataStore)
local TimeTick = 0
local TickGoal = 10
script.Parent.Parent = script.Parent.Parent.Head
local Player = game.Players.script.Parent.Parent.Parent.Name
if Player.Character.Humanoid.Health <= 0 then
script.Parent.Enabled = false
end
while wait(0.1) do
-- Get Data Stores
if Player == nil then return end
local dataStore = DataStoreModule.find("Player", Player.UserId)
if dataStore == nil then return end
if dataStore.State ~= true then return end
-- Set Overhead Values
script.Parent:WaitForChild("Frame"):WaitForChild("Username").Text = Player.Name..' <font color="rgb(255,255,100)">LVL'..dataStore.Value.Level..'</font>'
script.Parent:WaitForChild("Frame"):WaitForChild("Time").Text = dataStore.Value.Time
-- Check for forcefield
if Player.Character:FindFirstChild("ForceField") then
Player.Character.Humanoid.Health = Player.Character.Humanoid.Health+0.5
else
-- Time tick functions
if TimeTick < TickGoal then
TimeTick = TimeTick+1
elseif TimeTick == TickGoal and Player.Character.Humanoid.Health ~= 0 then
TimeTick = 0
dataStore.Value.Time += 1
dataStore.Leaderstats.Time.Value = dataStore.Value.Time
else
TimeTick = 0
end
end
end