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

Why does the script not switch between the two options?

Asked by 6 years ago
game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function()
           local bc = BrickColor.new("Neon orange")
                game.StarterGui:SetCore("ChatMakeSystemMessage", {
                Text = "Not bad... For an idiot that is..." or "Here goes another life..." ;
                Font = Enum.Font.Arial;
                Color = bc.Color;
                FontSize = Enum.FontSize.Size96;    
            })
        end)
    end)
end)

When I input the value of text, i expected the value to change everytime i die. should i use math.random?

1 answer

Log in to vote
0
Answered by 6 years ago
Edited 6 years ago

Hey RealRexTeam,

If you want to use a different string you're going to need to make a table of strings and then select one from the table randomly. Like this:

local strings = {"Whatever", "Ok, man..."}

local string = strings[math.random(#strings)];

print(string);

The reason yours doesn't work is because the or operator is like a ternary operator in which if the first option doesn't work it goes for the second one, it's useful for :FindFirstChild(), so if it couldn't find the first object, it would go for the second one.

Well, I hope i helped and have a nice day.

~~ KingLoneCat

0
but what would i put as the value of Text? Text = (string); ? RealRexTerm 21 — 6y
0
Just put the string as the text. Text = string; KingLoneCat 2642 — 6y
Ad

Answer this question