Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
1

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

Asked by 5 years ago
Edited 5 years ago

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

0
can you format your script into a code block? MrCatDoggo 213 — 5y
0
tell me which button that is? trickortreat333444 -6 — 5y
0
anddddd also post the error MrCatDoggo 213 — 5y
0
it is on line 11 trickortreat333444 -6 — 5y
View all comments (9 more)
0
i mean copy what the error says and post it MrCatDoggo 213 — 5y
0
i did trickortreat333444 -6 — 5y
0
you didnt parent your TimeValue. the TimeValue must be parented. In line one change it to Instance.new("NumberValue", game.Lighting) MrCatDoggo 213 — 5y
0
thanks man trickortreat333444 -6 — 5y
0
np MrCatDoggo 213 — 5y
0
it still says the same error trickortreat333444 -6 — 5y
0
Technically you dont need that long of a code. Nor do you need a time value. Let me show you some revised code MrCatDoggo 213 — 5y
0
please do trickortreat333444 -6 — 5y
0
script revised MrCatDoggo 213 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

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
0
This does the same MrCatDoggo 213 — 5y
0
did you test it trickortreat333444 -6 — 5y
0
I dont need to test it. I dont have the same gui and I know it works anyway MrCatDoggo 213 — 5y
Ad

Answer this question