Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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:

local Part = script.Parent
local ClickDetector = Part:WaitForChild("ClickDetector")
local Backpack = game.Players.LocalPlayer.Backpack

while wait() do
local tekst = script.Parent.SurfaceGui.TextLabel.Text

ClickDetector.MouseClick:connect(function()
	if Backpack.dziesiecminut == true then
	tekst = "Ten bilet jest wa?ny jeszcze przez" .. Backpack.dziesiecminut.Value.Value .. "sekund."
	wait(5)
	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)"
	elseif Backpack.piecminut == true then
	tekst = "Ten bilet jest wa?ny jeszcze przez" .. Backpack.piecminut.Value.Value .. "sekund."
	wait(5)
	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)"
	elseif Backpack.piecminut and Backpack.dziesiecminut == true then
	tekst = "Masz dwa bilety na raz. Musisz upu?ci? jeden z nich (kliknij Backspace na klawiaturze, z wyci?gni?tym biletem, który chcesz upu?ci?)."
	wait(5)
	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)"
	elseif Backpack.piecminut and Backpack.dziesiecminut == nil then
	tekst = "Nie masz biletu w ekwipunku. Upewnij si?, ?e nie masz swojego biletu w r?ce (je?li go masz)."
	wait(5)
	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)"
	end
end)
end

1 answer

✓ Accepted answer

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:

local Part = script.Parent
local ClickDetector = Part:WaitForChild("ClickDetector")
local Backpack = game.Players.LocalPlayer.Backpack

while wait() do
local tekst = script.Parent.SurfaceGui.TextLabel

ClickDetector.MouseClick:connect(function()
    if Backpack.dziesiecminut == true then
    tekst.Text = "Ten bilet jest wa?ny jeszcze przez" .. Backpack.dziesiecminut.Value.Value .. "sekund."
    wait(5)
    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)"
    elseif Backpack.piecminut == true then
    tekst.Text = "Ten bilet jest wa?ny jeszcze przez" .. Backpack.piecminut.Value.Value .. "sekund."
    wait(5)
    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)"
    elseif Backpack.piecminut and Backpack.dziesiecminut == true then
    tekst.Text = "Masz dwa bilety na raz. Musisz upu?ci? jeden z nich (kliknij Backspace na klawiaturze, z wyci?gni?tym biletem, który chcesz upu?ci?)."
    wait(5)
    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)"
    elseif Backpack.piecminut and Backpack.dziesiecminut == nil then
    tekst.Text = "Nie masz biletu w ekwipunku. Upewnij si?, ?e nie masz swojego biletu w r?ce (je?li go masz)."
    wait(5)
    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)"
    end
end)
end

This discussion is preserved as it was. New answers, comments, and votes are closed.