Text not changing

Hello, The text wont change, I have tryed 2 ways and it didnt work, what do I do?

script

local Text = script.Parent.Text


script.Value.Value.Touched:Connect(function()--value is child of script
	Text = "Hello"
	wait(0.3)
	Text = "Did you fall from that hole..?"
	wait(0.4)
	Text = "Thats bad"
	wait(0.3)
	Text = "you will need to fight the king if you want to escape"
	wait(2)
	Text = "But before..."
	wait(0.3)
	Text = "you will need to train"
	
end)

The Value’s value is the part

1 Like

Change

local Text = script.Parent.Text

To

local Text = script.Parent

And change every time you reference that Text variable to Text.Text. You can’t change text like that, you have to reference the object with the Text Property and retrieve Text yourself

Also, if I may ask, is this in a localscript? You may need to do some detection since once a single player touches it, all the text for others will change

1 Like

You are changing the varible to a string use local Text = script.Parent then
Text.Text

3 Likes

Late to ask but if i put the script in a local script
it will only show for the player that touches is only?

No, it will show for everyone, you need to do a statement to confirm that the player who touches is the same player. Basically, do something like this

local Text = script.Parent
local player = game.Players.LocalPlayer

script.Value.Value.Touched:Connect(function(hit)--value is child of script
	if not player.Character or not hit:IsDescendantOf(player.Character) then return end
	Text.Text = "Hello"
	wait(0.3)
	Text.Text = "Did you fall from that hole..?"
	wait(0.4)
	Text.Text = "Thats bad"
	wait(0.3)
	Text.Text = "you will need to fight the king if you want to escape"
	wait(2)
	Text.Text = "But before..."
	wait(0.3)
	Text.Text = "you will need to train"
end)

This is to ensure that only the player who touched it will get tehir text changed, remember to put the LocalScript in a palce where it can actually run, such as StarterPlayerScripts for example.

Or you could just put this in a regular script and get the player via the parameter you get from touched, which is the thing that hit the part and just get the player and change it from there

2 Likes

as long as its not in a server related service yes
else it wont work at all

2 Likes