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

How do I change the string value "Text" in "TextLabel"?

Asked by 3 years ago

Im trying to make a death screen thing where when you die it chooses random text. Heres the string randomizer script i have

local RandomNumber = math.random(1,20)
local Responses = {
    "Well, you died. That sucks, try again.",
    "Stop dying! This is boring to watch!!", 
    "You didn't even survive.. lame..", 
    "What have you done",
    "You'd still be alive if you got off that damn phone",
    "Oof. Now you gotta do it all over again.",
    "This is dissapointing.",
    "If you die again, then you die. But I recommend you dont die.",
    "I hope you learned from your mistake",
    "You died for a reason, noob",
    "Huh, something just stopped. Oh, it was your heart",
    "Blame it on lag",
    "hahaahahahahahhahahhahahahaha",
    "Wow that was great! (said no one) ",
    "Its fun to watch you continuously fail and fail",
    "Your character infinetly falls into the void",
    "Hey loser, you died",
    "My dissapointment is immeasurable and my day is ruined",
    "You had a good life. Until you pathetically died.",
    "You died, but look on the bright side! You get infinite tries",}
local FinalMessage = (Responses[RandomNumber])

-so theres a variable that chooses a random number between 1 and 20 -a variable that is a table that has 20 different string values -a variable called FinalMessage which is the responses and the random number choosing a random value

so then i try this

game.StarterGui.DeathGui.Frame.TextLabel.Text = FinalMessage

the script is in ServerScriptStorage idk if that makes a difference

when it runs the text doesnt change so thats it.

0
also when i print it, it works. It just wont change the value of the text though likejagar 17 — 3y

2 answers

Log in to vote
1
Answered by
hoth7 45
3 years ago
Edited 3 years ago

So, basically, you'd have to use a Module Script in order to be able to access the table if you're firing the message from a different script. Module scripts are a kind of script with the main purpose of storing data, such as tables. A script can retrieve information from a module script. I've encountered this problem many times.

1
I don't know much on Module scripting, sorry if it was unclear! hoth7 45 — 3y
0
That's a pretty good explanation of what a module script is. But you can also think of it as an object (in programming) with its own functions and variables. Vinceberget 1420 — 3y
Ad
Log in to vote
0
Answered by 3 years ago

Nevermind... im such a newbie my bad i got it dont how do i delete this post i dont wanna waste anyones time by looking at it

0
You dont need to delete it, you can mark it as answered. generalYURASKO 144 — 3y

Answer this question