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

attempt to concatenate local 'Variable' (a nil value) / Error Message?

Asked by 5 years ago
Edited 5 years ago

Well I've made a script, where the Server sends the time of lighting to Client. The Clientside script seems to work fine, but a error in the Output pops up the whole time.

22:06:24.160 - Players.bbudder.PlayerGui.CS.Main.TimeModule [FE]:6: attempt to concatenate local 'STime' (a nil value)

22:06:24.162 - Stack Begin

22:06:24.163 - Script 'Players.bbudder.PlayerGui.CS.Main.TimeModule [FE]', Line 6

22:06:24.164 - Stack End

Clientside:

local CoreGui = game.Players.LocalPlayer.PlayerGui
local Time = CoreGui.CS.Main.TimeDisplay
local Event = game.ReplicatedStorage.ServerTime

Event.OnClientEvent:Connect(function(STime)
Time.Text = ""..STime
end)

Serverside:

local Event = game.ReplicatedStorage.ServerTime
while true do
    wait(1)
    local STime = game.Lighting.TimeOfDay
    Event:FireAllClients(STime)
end

Any answers would be appreciated. How can I avoid this?

++EDIT Even if I replace / Time.Text = ""..STime / with /Time.Text = STime / then this message pops up:

22:23:16.810 - Players.bbudder.PlayerGui.CS.Main.TimeModule [FE]:6: bad argument #3 to > 'Text' (string expected, got nil)

0
Try Time.Text = STime User#19524 175 — 5y
0
Sorry does not. If I do that then the error message is diffrent: 22:20:10.230 - Players.bbudder.PlayerGui.CS.Main.TimeModule [FE]:6: bad argument #3 to 'Text' (string expected, got nil) bbudder 7 — 5y
0
*Sorry does not work bbudder 7 — 5y
0
Try tostring(STime) User#22219 20 — 5y
View all comments (3 more)
0
It think without tostring, it would be like (for example) 12:34:56, which should be "12:34:56". User#22219 20 — 5y
0
Time.Text = tostring(STime) User#22219 20 — 5y
0
The error is gone, But instead of the time appearing. It's just displaying "nil" in the text. bbudder 7 — 5y

2 answers

Log in to vote
0
Answered by 5 years ago

You can use tostring The wiki page say that it's value type is a string.

0
^ I don't know if I should be a comment or not. User#22219 20 — 5y
Ad
Log in to vote
0
Answered by 5 years ago

So THEY did fixed my problem about the Error using tostring. But the problem is that the CLIENT SIDE script is firing, EVEN if the SERVER is not firing.

So yes, using tostring fixed the error stuff.

0
I doubt tonumber will work, there are plenty of YouTube tutorial of how to do them. User#22219 20 — 5y

Answer this question