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

My text doesn't change when clicked on the part. Help?

Asked by 5 years ago
Edited 5 years ago

My text doesn't change, when it's clicked. I know the code is long, you can point out other errors in here and suggest a solution to these as well. (the "dziesiecminut" or "piecminut" are the things that its supposed to check value of, to display it.)
And the question marks are polish accenting letters (z with a dot above it and stuff like that), they turned into it for some reason.

My LocalScript inside the part that im clicking:

01local Part = script.Parent
02local ClickDetector = Part:WaitForChild("ClickDetector")
03local Backpack = game.Players.LocalPlayer.Backpack
04 
05while wait() do
06local tekst = script.Parent.SurfaceGui.TextLabel.Text
07 
08ClickDetector.MouseClick:connect(function()
09    if Backpack.dziesiecminut == true then
10    tekst = "Ten bilet jest wa?ny jeszcze przez" .. Backpack.dziesiecminut.Value.Value .. "sekund."
11    wait(5)
12    tekst = "Je?li chcesz sprawdzi? wa?no?? biletu, kliknij ten ekran. (trzeba mie? tylko jeden bilet w ekwipunku, nie mo?e by? on wyci?gni?ty, i wa?no?? podawana w sekundach)"
13    elseif Backpack.piecminut == true then
14    tekst = "Ten bilet jest wa?ny jeszcze przez" .. Backpack.piecminut.Value.Value .. "sekund."
15    wait(5)
View all 27 lines...

1 answer

Log in to vote
0
Answered by
Txeer 46
5 years ago
Edited 5 years ago

When you say tekst = (text) you are not changing the text but the variable "tekst" instead. For example, when you wrote tekst = "Ten bilet jest wa?ny jeszcze przez", tekst no longer is script.Parent.SurfaceGui.TextLabel.Text because it is now the string "Ten bilet jest wa?ny jeszcze przez." You can solve this is by setting the variable to just the TextLabel then put tekst.Text = (text).

Updated code:

01local Part = script.Parent
02local ClickDetector = Part:WaitForChild("ClickDetector")
03local Backpack = game.Players.LocalPlayer.Backpack
04 
05while wait() do
06local tekst = script.Parent.SurfaceGui.TextLabel
07 
08ClickDetector.MouseClick:connect(function()
09    if Backpack.dziesiecminut == true then
10    tekst.Text = "Ten bilet jest wa?ny jeszcze przez" .. Backpack.dziesiecminut.Value.Value .. "sekund."
11    wait(5)
12    tekst.Text = "Je?li chcesz sprawdzi? wa?no?? biletu, kliknij ten ekran. (trzeba mie? tylko jeden bilet w ekwipunku, nie mo?e by? on wyci?gni?ty, i wa?no?? podawana w sekundach)"
13    elseif Backpack.piecminut == true then
14    tekst.Text = "Ten bilet jest wa?ny jeszcze przez" .. Backpack.piecminut.Value.Value .. "sekund."
15    wait(5)
View all 27 lines...
Ad

Answer this question