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

My seconds to minutes function isnt displaying minutes and seconds on a gui, help please?

Asked by 7 years ago

Here is the whole script. My issue is that the function secondstotimer will not change into 3 minutes, instead it shows 180 seconds. Can anyone help?

local gui = script.Parent
local replicatedstorage = game:GetService("ReplicatedStorage")
local statustag = replicatedstorage:WaitForChild("StatusTag")
local timertag = replicatedstorage:WaitForChild("TimerTag")
local statustitle = gui:WaitForChild("StatusTitle")
local event = replicatedstorage:WaitForChild("RemoteEvent")
local resultprompt = gui:WaitForChild("ResultPrompt")
local resultname = resultprompt:WaitForChild("ResultName")
local resultdesc = resultprompt:WaitForChild("ResultDescription")
local classprompt = gui:WaitForChild("ClassPrompt")
local classname = classprompt:WaitForChild("ClassName")
local classdesc = classprompt:WaitForChild("ClassDescription")

function secondstotimer(seconds)
    local minutes = math.floor(seconds / 60)
    local remainingseconds = seconds % 60
    if remainingseconds <= 0 then
    remainingseconds = "00"
    elseif remainingseconds <= 9 then
        remainingseconds = "0" .. tostring(remainingseconds)
        else
         remainingseconds = tostring(remainingseconds)
        end
    return tostring(minutes) ..":" .. remainingseconds
end
function updatestatus()
    if timertag.Value < 0 then
    statustitle.Text = statustag.Value
    else 
    statustitle.Text = statustag.Value .."  (" ..timertag.Value ..")"
    end
    if statustag.Value == "Intermission" then
        statustitle.TextColor3 = Color3.new(14/255 , 154/255 , 23/255)
    elseif statustag.Value == "Match" then
        statustitle.TextColor3 = Color3.new(227/255, 250/255, 18/255)
    elseif statustag.Value == "Loading Map" or statustag.Value == "Waiting For Players" then
        statustitle.TextColor3 = Color3.new(56/255, 241/255, 250/255)
    end
end

timertag.Changed:connect(updatestatus)
statustag.Changed:connect(updatestatus)
updatestatus()

event.OnClientEvent:connect(function(...)
    local tuple = {...}
    if tuple[1] == "Result" then
        if tuple[2] == "SerialKillerWin" then
            resultname.Text = "Serial Killer Wins!"
            resultname.TextColor3 = Color3.new(214/255, 0 , 0)
            resultdesc.Text = "All innocents were murdered."
        else
            resultname.Text = "Innocents Win!"
            resultname.TextColor3 = Color3.new()
            resultdesc.Text = "The serial killer was eliminated!"
        end
        resultprompt.Visible = true
        resultprompt.Position = UDim2.new(0, -400, .5, -92)
        resultprompt:TweenPosition(UDim2.new(.5, -170, .5, -197), "Out", "Quad", 1)
        wait(8)
        resultprompt:TweenPosition(UDim2.new(1, 60, .5, -92), "Out", "Quad")
    elseif
        tuple[1] == "Class" then
        if tuple[2] == "SerialKiller" then
            classname.Text = "You are the serial killer."
            classname.TextColor3 = Color3.new(214/255, 0 , 0)
            classdesc.Text = "Your goal is to murder all the innocent people with your cleaver and let no one escape!"
elseif tuple[2] == "Sheriff" then
            classname.Text = "You are the sheriff!"
            classname.TextColor3 = Color3.new(223/255, 217/255, 29/255)
            classdesc.Text = "Your goal is to save and protect all the innocent people and eliminate the serial killer."
        else
            classname.Text = "You are an innocent bystander."
            classname.TextColor3 = Color3.new(71/255, 176/255, 1)
            classdesc.Text = "Witness the serial killer's crimes and report them to the sherrif to help eliminate the murderer!"
        classprompt.Visible = true
        classprompt.Position = UDim2.new(0, -400, .5, -92)
        classprompt:TweenPosition(UDim2.new(.5, -170, .5, -197), "Out", "Quad", 1)
        wait(8)
        classprompt:TweenPosition(UDim2.new(1, 60, .5, -92), "Out", "Quad")
        end
    end
end)

1
It doesn't look like you ever called secondstotimer Lucas_Lua 1 — 7y

1 answer

Log in to vote
0
Answered by
P100D 590 Moderation Voter
7 years ago

You don't seem to be calling the secondstotimer() function anywhere in your script. Make sure you're calling the function where you need it to be called.

Side note: :connect() is deprecated, use :Connect() instead. ROBLOX is pushing for PascalCase instead of camelCase

Ad

Answer this question