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

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

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)

7 comments

0

Try Time.Text = STime

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)

0

*Sorry does not work

0

Try tostring(STime)

0

It think without tostring, it would be like (for example) 12:34:56, which should be "12:34:56".

0

Time.Text = tostring(STime)

0

The error is gone, But instead of the time appearing. It's just displaying "nil" in the text.

2 answers

✓ Accepted answer

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

1 comment

0

^ I don't know if I should be a comment or not.

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