The error is inside line of the script
I think I figured it out, huh.
Change the variable Time
to something else, it has the same name as the parameter in the function I made, so that is probably the reason why the error is happening on line 5.
Example:
local status = game.ReplicatedStorage.Status
local TimeGui = script.parent.Time
function ConvertClock(Time)
local minutes = math.floor(Time / 60)
local seconds = math.floor(Time % 60)
if tostring(seconds):len() == 1 then
seconds = tostring("0"..seconds)
end
return {tostring(minutes), tostring(seconds)}
end
status.Changed:Connect(function()
local c = ConvertClock(tonumber(status.Value))
TimeGui.Text = c[1]..":"..c[2]
end)
I changed the variable to TimeText but the same error still happens on line 5.
Is status
a string value?
-- Character limit.
Yes it is because I want the text to display Time: (number)
Maybe try adding a :WaitForChild()
function to get status
like so:
local status = game.ReplicatedStorage:WaitForChild("Status")
It still displays the same error when testing
I have no clue then, just try to change some stuff in the code. Iāll think of a solution in the meantime.
The error might have been happening because you forgot to capitalize the āpā in parent on line 2, a fix to that would be:
local TimeGui = script.Parent.Time
The error keeps happening. Also, the original purpose of the local script is to copy what the status value is and put it in the timer text, so the issue is with the server script
Send me the entire server script then.
local roundlength = 300
local intermissionlength = 0
local InRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status
local Camera = workspace.CurrentCamera
function ConvertClock(Time)
function ConvertClock(Time)
local minutes = math.floor(Time / 60)
local seconds = math.floor(Time % 60)
if tostring(seconds):len() == 1 then
seconds = tostring("0"..seconds)
end
return {tostring(minutes), tostring(seconds)}
end
for i = 1, 120 do
local c = ConvertClock(i)
print(c[1]..":"..c[2])
task.wait(1)
end
end
local function Teleport(Location)
if not workspace.Spawns:FindFirstChild(Location) then return end
for _, player in pairs(game.Players:GetPlayers()) do
local char = player.Character or player.CharacterAdded:wait()
char.HumanoidRootPart.CFrame = workspace.Spawns[Location].CFrame
end
end
InRound.Changed:Connect(function()
if InRound.Value == false then
Teleport("LobbyTP")
end
end)
local function roundTimer()
while wait() do
for i = intermissionlength, 0, -1 do
InRound.Value = false
wait(1)
Status.Value = "TIME: ".. i ..""
end
for i = roundlength, 0, -1 do
InRound.Value = true
wait(1)
Status.Value = "TIME: ".. i ..""
if i <= 0 then
Ended()
end
end
end
end
spawn(roundTimer)
function Ended()
for _, player in pairs(game.Players:GetPlayers()) do
pcall(function()
player.PlayerGui.EndGui.CameraHandler.Disabled = false
task.delay(5,function()
player.PlayerGui.EndGui.CameraHandler.Disabled = true
end)
end)
end
game.Workspace.Enemies:ClearAllChildren()
game.Workspace.Pickups:ClearAllChildren()
end
Also, when I changed the local script back to original the issue was fixed. But the time is still in seconds format in status
If you can, send me a place download so I can test the issue on my own terms, itās fine if you donāt want to though.
I donāt know how to send that kind of download.
Thatās fine, Iāll just test with a mock up of the place.
Are there any errors for the server script?
No there arenāt any errors. I think whatās wrong with the server script is I might have put the format function in the wrong place?
Try replacing the old server script with this:
I barely made any changes, there are errors, use the old one.
local roundlength = 300
local intermissionlength = 0
local InRound = game.ReplicatedStorage.InRound
local Status = game.ReplicatedStorage.Status
local Camera = workspace.CurrentCamera
function ConvertClock(Time)
local minutes = math.floor(Time / 60)
local seconds = math.floor(Time % 60)
if tostring(seconds):len() == 1 then
seconds = tostring("0"..seconds)
end
return {tostring(minutes), tostring(seconds)}
end
local function Teleport(Location)
if not workspace.Spawns:FindFirstChild(Location) then return end
for _, player in pairs(game.Players:GetPlayers()) do
local char = player.Character or player.CharacterAdded:wait()
char.HumanoidRootPart.CFrame = workspace.Spawns[Location].CFrame
end
end
InRound.Changed:Connect(function()
if InRound.Value == false then
Teleport("LobbyTP")
end
end)
local function roundTimer()
while wait() do
for i = intermissionlength, 0, -1 do
InRound.Value = false
wait(1)
Status.Value = "TIME: ".. i ..""
end
for i = roundlength, 0, -1 do
InRound.Value = true
wait(1)
Status.Value = "TIME: ".. i ..""
if i <= 0 then
Ended()
end
end
end
end
spawn(roundTimer)
function Ended()
for _, player in pairs(game.Players:GetPlayers()) do
pcall(function()
player.PlayerGui.EndGui.CameraHandler.Disabled = false
task.delay(5,function()
player.PlayerGui.EndGui.CameraHandler.Disabled = true
end)
end)
end
game.Workspace.Enemies:ClearAllChildren()
game.Workspace.Pickups:ClearAllChildren()
end
I think the code in the ConvertClock function should go in this function. I will try doing that.
local function roundTimer()
while wait() do
for i = intermissionlength, 0, -1 do
InRound.Value = false
wait(1)
Status.Value = "TIME: ".. i ..""
end
for i = roundlength, 0, -1 do
InRound.Value = true
wait(1)
Status.Value = "TIME: ".. i ..""
if i <= 0 then
Ended()
end
end
end
end