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

Anybody can fix my script on line 11? It has an error that i need help solving


TimeValue = Instance.new("NumberValue")

while true do

local PlayerGui = game.Players.LocalPlayer.PlayerGui
local TextLabel = PlayerGui.ScreenGui.TextLabel
 
if game:GetService("Lighting").ClockTime >= 14 then
	TimeValue = 6
	TextLabel.Text = "Time:".. TimeValue.Value..":00".. "AM" .. "[Day Shift]"
end

if game:GetService("Lighting").ClockTime >= 15 then
	TimeValue = 7
	TextLabel.Text = "Time:".. TimeValue.Value..":00".. "AM" .. "[Day Shift]"
end

if game:GetService("Lighting").ClockTime >= 16 then
	TimeValue = 8
	TextLabel.Text = "Time:".. TimeValue.Value..":00".. "AM" .. "[Day Shift]"
end

if game:GetService("Lighting").ClockTime >= 16.5 then
	TimeValue = 9
	TextLabel.Text = "Time:".. TimeValue.Value..":00".. "AM" .. "[Day Shift]"
end

if game:GetService("Lighting").ClockTime >= 16.8 then
	TimeValue = 10
	TextLabel.Text = "Time:".. TimeValue.Value..":00".. "AM" .. "[Day Shift]"
end

if game:GetService("Lighting").ClockTime >= 16.8 then
	TimeValue = 10
	TextLabel.Text = "Time:".. TimeValue.Value..":00".. "AM" .. "[Day Shift]"
end


if game:GetService("Lighting").ClockTime >= 17 then
	TimeValue = 11
	TextLabel.Text = "Time:".. TimeValue.Value..":00".. "AM" .. "[Day Shift]"
end

if game:GetService("Lighting").ClockTime >= 17.5 then
	TimeValue = 12
	TextLabel.Text = "Time:".. TimeValue.Value..":00".. "PM" .. "[Day Shift]"
end

if game:GetService("Lighting").ClockTime >= 17.8 then
	TimeValue = 1
	TextLabel.Text = "Time:".. TimeValue.Value..":00".. "PM" .. "[Day Shift]"
end

if game:GetService("Lighting").ClockTime >= 18 then
	TimeValue = 2
	TextLabel.Text = "Time:".. TimeValue.Value..":00".. "PM" .. "[Day Shift]"
end

if game:GetService("Lighting").ClockTime >= 18.5 then
	TimeValue = 3
	TextLabel.Text = "Time:".. TimeValue.Value..":00".. "PM" .. "[Day Shift]"
end

if game:GetService("Lighting").ClockTime >= 18.7 then
	TimeValue = 4
	TextLabel.Text = "Time:".. TimeValue.Value..":00".. "PM" .. "[Day Shift]"
end

if game:GetService("Lighting").ClockTime >= 18.9 then
	TimeValue = 5
	TextLabel.Text = "Time:".. TimeValue.Value..":00".. "PM" .. "[Day Shift]"
end

if game:GetService("Lighting").ClockTime >= 19 then
	TimeValue = 6
	TextLabel.Text = "Time:".. TimeValue.Value..":00".. "PM" .. "[Day Shift]"
end











end






















20:47:13.183 - Players.jkiop23.PlayerGui.ScreenGui.TextLabel.LocalScript:11: attempt to index global 'TimeValue' (a number value)

this was the error

13 comments

0

can you format your script into a code block?

0

tell me which button that is?

0

anddddd also post the error

0

it is on line 11

0

i mean copy what the error says and post it

0

i did

0

you didnt parent your TimeValue. the TimeValue must be parented. In line one change it to Instance.new("NumberValue", game.Lighting)

0

thanks man

0

np

0

it still says the same error

0

Technically you dont need that long of a code. Nor do you need a time value. Let me show you some revised code

0

please do

0

script revised

1 answer

Your script is to long and because you have cut off some code your "Line 11" is actually line 6.

Heres a shorter and speedier bit of code that does the same:

local PlayerGui = game.Players.LocalPlayer.PlayerGui
local TextLable = PlayerGui.ScreenGui.TextLabel

local Time = game:GetService("Lighting").ClockTime

if Time < 13 then
	TextLabel.Text = "Time:".. Time ..":00".. "AM" .. "[Day Shift]"
else
	TextLabel.Text = "Time:".. Time - 12 ..":00".. "PM" .. "[Day Shift]"
end

3 comments

0

This does the same

0

did you test it

0

I dont need to test it. I dont have the same gui and I know it works anyway

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