Attempt to concatenate string with nil

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? Keep it simple and clear! I’m Making A Working Clock.

  2. What is the issue? Include screenshots / videos if possible! It Errors Saying “attempt to concatenate string with nil”

  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub? Yes But None Have The Same Type.

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

ServerScript:

local OClock = "AM"
local TimeBetweenMinutes = 30
local TimeNow = StartingTime

local ChangeUITimer = game.ReplicatedStorage.RemoteEvents.ChangeUITimer

function Hour()
	if TimeNow == 13 and OClock == "AM" then
		OClock = "PM"
		TimeNow = 1
	elseif TimeNow == 13 and OClock == "PM" then
		OClock = "AM"
		TimeNow = 8
	end
	ChangeUITimer:FireAllClients(TimeNow, OClock)
	TimeNow = TimeNow + 1
end

while true do
	Hour()
	wait(2)
end

Local Script:

game.ReplicatedStorage.RemoteEvents.ChangeUITimer.OnClientEvent:Connect(function(player, TimeNow, Oclock)
	script.Parent:WaitForChild("GameTime").Text = TimeNow .. ":00" .. Oclock
end)

Help As This Is Important For My Game…

Seems like you meant OClock, not Oclock.

no thats how its spelled in the remote event. It doesnt need to be like what the sent value is called.

You should probably edit your post to include the rest of your script, then.

that is all of the scripts with the clock-

There you go. Your OnClientEvent should not have the player parameter, just the TimeNow and Oclock.

1 Like

It’s because you entered a player parameter – for OnClientEvent it doesn’t pass the player since FireClient/FireAllClients will already call to X player (in fact, if you print the player variable you’ll notice it’s one of the values that was sent). Simply remove that parameter and it should work as intended :+1: