#How to fix this code?

1 messages · Page 1 of 1 (latest)

mighty spade
#

local HealthDisplay = game.ServerStorage:WaitForChild("HealthGui")
local HealthText = HealthDisplay.TextLabel
----------<TIME>-------------
local timeDisplay = game.ServerStorage:WaitForChild("TimeGui")
local timeText = timeDisplay.TextLabel
-------------------------><CLONE DISPLAY><-----------------------------
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAdded:Connect(function(character)
----------------- HEALTH DISPLAY --------------------
local character = plr.Character
local head = character:FindFirstChild("Head")
local humanoid = character:FindFirstChild("Humanoid")
----------------------- <>----------------------------------

 ---------------- TIME DISPLAY ----------------------------
 local leaderstats = plr:FindFirstChild("leaderstats")
 local Time = leaderstats:WaitForChild("Time Alive")
 
 
 -----------------------------------------------------------
 local tD = timeDisplay:Clone()
  tD.Parent = head
  tD.Adornee = head
  tD.TextLabel.Text = Time.Value
 local Display = HealthDisplay:Clone()
    Display.Parent = head
    Display.Adornee = head
 local HealthText = Display:WaitForChild("TextLabel")
 HealthText.Text = humanoid.Health.." HP"

 if humanoid.Health >= 60 then
    HealthText.TextColor3 = Color3. fromRGB(99, 255, 99)
 end

 if humanoid.Health <= 60 then
    HealthText.TextColor3 = Color3. fromRGB(255, 253, 130)
 end

 if humanoid.Health <= 30 then
    HealthText.TextColor3 = Color3. fromRGB(255, 52, 55)
 end
end)

end)

mighty spade
#

I want it to display time

#

but it cant seem to find the Time

#

instance

empty gate
mighty spade
#

There isnt an error

#

It just doesnt display

#

gimme a sec ill send a video

#

I just started scripting today and i got help from some other guys but i understand the code

#

im just new to the basics like how to identify the instances in another script

empty gate
#

you only set it once

#

when time.value is at 0

#

put it in a loop

#

using heartbeat or renderstepped

mighty spade
#

oh thats right

#

how do i do a heartbeat?

#

heartbeat()
local tD = timeDisplay:Clone()
tD.Parent = head
tD.Adornee = head
tD.TextLabel.Text = Time.Value
return end?

empty gate
#
local RunService = game:GetService("RunService")

RunService.Heartbeat:Connect(function
 --code here
end)
mighty spade
#

oh wow

empty gate
#

it runs every physic tick

mighty spade
#

thanks for teaching me

empty gate
#

i think its 60 times per secound

mighty spade
#

so it is 60 fps of running the players time right?

#

tps i mean

#

do you think there is an easier way?

empty gate
#

it will update the player time label 60 times per seocund

#

just put this inside it
tD.TextLabel.Text = Time.Value

mighty spade
#

oh ok

empty gate
#

it shouldwork

mighty spade
#

im just concerned about lag

#

but im sure it wont be to bad

empty gate
#

lots of games use this

mighty spade
#

local RunService = game:GetService("RunService")

    RunService.Heartbeat:Connect(function ()
        local tD = timeDisplay:Clone()
        tD.Parent = head
        tD.Adornee = head
        tD.TextLabel.Text = Time.Value
    end)
#

made it like this

empty gate
#

no

#

that will cause lag

mighty spade
#

oh ok

empty gate
#

you only need to update the value

#
local RunService = game:GetService("RunService")

RunService.Heartbeat:Connect(function ()
    tD.TextLabel.Text = Time.Value
end)
mighty spade
#

local RunService = game:GetService("RunService")
local tD = timeDisplay:Clone()
tD.Parent = head
tD.Adornee = head
RunService.Heartbeat:Connect(function ()

        tD.TextLabel.Text = Time.Value
    end)
#

this ok?

mighty spade
#

😄

#

ty bro

empty gate
#

no problem

mighty spade
#

i ahve one more question

#

does roblox automatically abbreviate

#

million or billion?

empty gate
mighty spade
#

i think its fine

#

nobodys gonna afk for a billion seconds

#

ty bro

empty gate
mighty spade
#

yeah crazy

acoustic gladeBOT
#

studio** You are now Level 5! **studio

dull vine
#

what is this ai ah script

#

🙏🙏