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

Why won't this localscript update a textlabel?

Asked by 10 years ago
local gui = script.Parent

local player = game.Players.LocalPlayer

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 pointsvalue = player.leaderstats:WaitForChild("Points")
local creditsvalue = player:WaitForChild("Credits")
local multipliervalue = player:WaitForChild("Multiplier")

local resultprompt = gui:WaitForChild("ResultPrompt")
local resultname = resultprompt:WaitForChild("ResultName")
local resultdescription = resultprompt:WaitForChild("ResultDescription")

local classprompt = gui:WaitForChild("ClassPrompt")
local classname = classprompt:WaitForChild("ClassName")
local classdescription = classprompt:WaitForChild("ClassDescription")

local creditstotal = gui.ShopPrompt.ShopFrame:WaitForChild("Credits")

local multiplierprompt = gui:WaitForChild("MultiplierPrompt")
local multiplierbutton = multiplierprompt:WaitForChild("Button")
local multipliertotal = multiplierprompt:WaitForChild("MultiplierTotal")

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 .. "  (" .. secondstotimer(timertag.Value) .. ")"
    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] == "MurdererWin" then
            resultname.Text = "Murderer Wins"
            resultname.TextColor3 = Color3.new(1,0,0)
            resultdescription.Text = "The murderer killed everyone"
        else
            resultname.Text = "Players Wins"
            resultname.TextColor3 = Color3.new(0,1,0)
            resultdescription.Text = "The players defeated the murderer"
        end
        resultprompt.Visible = true
        resultprompt.Position = UDim2.new(0,-400,0.5,-92)
        resultprompt:TweenPosition(UDim2.new(0.5,-170,0.5,-92), "Out", "Quad", 1)
        wait(7)
        resultprompt:TweenPosition(UDim2.new(1,60,0.5,-92), "Out", "Quad", 1)
    elseif tuple[1] == "Class" then
        if tuple[2] == "Murderer" then
            classname.Text = "Murderer"
            classname.TextColor3 = Color3.new(1,0,0)
            classdescription.Text = "Murder everyone without getting spotted"
        elseif tuple[2] == "Sheriff" then
            classname.Text = "Sheriff"
            classname.TextColor3 = Color3.new(0,0,1)
            classdescription.Text = "Shoot the murderer, don't kill innocents"
        else
            classname.Text = "Innocent"
            classname.TextColor3 = Color3.new(0,1,0)
            classdescription.Text = "Help the sheriff find the murderer"
        end
        classprompt.Visible = true
        classprompt.Position = UDim2.new(0,-400,0.5,-92)
        classprompt:TweenPosition(UDim2.new(0.5,-170,0.5,-92), "Out", "Quad", 1)
        wait(7)
        classprompt:TweenPosition(UDim2.new(1,60,0.5,-92), "Out", "Quad", 1)
    end
end)    

I have this from the mad bloxxer. It worked before, then one day I wasn't online, so I did some stuff, like build some extra thing, didn't touch script though, and now it dosen't work? Anyone help.

Answer this question