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

Why won't it change the text on a textlabel?

Asked by
bossay6 62
7 years ago
Edited 7 years ago
local question = script.Parent.Parent
local fr2 = script.Parent.Parent.Parent.Parent.Frame2
script.Parent.MouseButton1Click:connect(function()
    script.Parent.Parent.Parent.Visible = false
    wait(1) 
    local Response = math.random(5)
    wait(1)
    if Response == 1 then
    fr2.X.Text = "You asked "..question.Text.." and it replied with Yes."
    if Response == 2 then
    fr2.X.Text = "You asked "..question.Text.." and it replied with No."
    if Response == 3 then
    fr2.X.Text = "You asked "..question.Text.." and it replied with Maybe."   
    if Response == 4 then
    fr2.X.Text = "You asked "..question.Text.." and it replied with Probably." 
    if Response == 5 then
    fr2.X.Text = "You asked "..question.Text.." and it replied with Probably not."   
    end  
    end
    end
    end
    end
    fr2.Visible = true
    wait(5)
    cd.MaxActivationDistance = 32
    fr2.Visible = false 
end)

No errors Local Script

1 answer

Log in to vote
0
Answered by
VoltCode 101
7 years ago
local question = script.Parent.Parent
local fr2 = script.Parent.Parent.Parent.Parent.Frame2
script.Parent.MouseButton1Click:Connect(function()
    script.Parent.Parent.Parent.Visible = false
    wait(1) 
    local Response = math.random(5)
    wait(1)
    if Response == 1 then
    fr2.X.Text = "You asked "..question.Text.." and it replied with Yes."
    end

    if Response == 2 then
    fr2.X.Text = "You asked "..question.Text.." and it replied with No."
    end
    if Response == 3 then
    fr2.X.Text = "You asked "..question.Text.." and it replied with Maybe."   
    end
    if Response == 4 then
    fr2.X.Text = "You asked "..question.Text.." and it replied with Probably." 
    end
    if Response == 5 then
    fr2.X.Text = "You asked "..question.Text.." and it replied with Probably not."   
    end
    fr2.Visible = true
    wait(5)
    cd.MaxActivationDistance = 32
    fr2.Visible = false 
end)

You had every if condition within one another, so if response == 1 then if response == 2. That's how your's was.

Ad

Answer this question