How to change textlabel text using script

Hello, anyone know how to Textlabel text when this script has detected the word “Evasion”

Here’s the script:

` local EvasionCharge = 600`

        local sentancebox = script.Parent.Parent.SentenceBox

        script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
        	if script.Parent.Text == "Evasion" then
        		
        		
        	end			
        	
        end)

thank you

5 Likes

You could simply add script.Parent.Text = "TextHere"?

4 Likes

Is this a server script or a local script?

local scriptsssssssssssssssssssssss

So what I said is going to work perfectly fine.

Okay so what DanillochRBX said will work

if script.Parent.Text == "Evasion" then
	script.Parent.Text = "Text" -- Put whatever you want the text to say here
end
2 Likes

yeah it works, thank you alot man! (I didn’t know it was this easy, i was thinking about same that you but I tought it not gonna work!

2 Likes

There’s no harm in trying things out. Testing and seeing if you get an error means you’ll get a response in 5 seconds instead of 5 minutes.

4 Likes

yeah I know, now I’m gonna test them out

ok i have multiple same scripts with diff information why it’s giving only the one number

When you mean “Different Information”, do you mean you’re trying to change the text in different scripts?

In same script but with other number and it detects other text

like this

local TreasonCharge = 1000

script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
	if script.Parent.Text == "Treason" then
		wait(1)
		script.Parent.Parent.SentenceBox.Text = TreasonCharge

	end
end)

---
local HighTreasonCharge = 1200

script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
	if script.Parent.Text == "High Treason" then 
		wait(1)
		script.Parent.Parent.SentenceBox.Text = HighTreasonCharge
	end
end)
1 Like

You don’t have to keep checking for multiple events whenever you check for a TextProperty change, you could just encase it all in 1 event like so:

local TreasonCharge = 1000
local HighTreasonCharge = 1200

script.Parent:GetPropertyChangedSignal("Text"):Connect(function()
	if script.Parent.Text == "High Treason" then 
		wait(1)
		script.Parent.Parent.SentenceBox.Text = HighTreasonCharge
    elseif script.Parent.Text == "Treason" then
        wait(1)
        script.Parent.Parent.SentenceBox.Text = TreasonCharge
	end
end)

oh thanks lemme test ittttttttt

If for some reason it doesn’t work, try to convert your TreasonCharge variables to strings instead

local TreasonCharge = "1000"
local HighTreasonCharge = "1200"
2 Likes

Still doesn’t work out, still putting the 450 without any reason

Are there any other scripts that could be overlapping the main script from changing the Text?

No, there aren’tt any other scripts

What are you trying to achieve in this? It can give us a better understanding and help you faster