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

My script is supposed to change the text on a textbox but it isn't, help?

local text = game.Workspace.Sign.Sign.SurfaceGui.TextBox.Text
local debounce = true

script.Parent.Touched:Connect(function(hit)
	if debounce == true then
		debounce = false
		print("stepped on")
		text = "insert flash text"
		wait(2)
		text = "insert normal text"
		debounce = true
	end
end)

This is my code. It's not complicated and I didn't expect to get stuck here, but here I am. The output successfully prints "stepped on"

1 answer

✓ Accepted answer

If you write

local text = game.Workspace.Sign.Sign.SurfaceGui.TextBox.Text

your variable "text" would be equal to your TextBox Text, it will not refer to the TextBox text and in the line 08 you set the variable to "insert flash text" instead of change the object text

you need to put:

local text = game.Workspace.Sign.Sign.SurfaceGui.TextBox --text refers to your object
local debounce = true

script.Parent.Touched:Connect(function(hit)
    if debounce == true then
        debounce = false
        print("stepped on")
        text.Text = "insert flash text" --You change the object.Text
        wait(2)
        text.Text = "insert normal text" --Same here
        debounce = true
    end
end)

sorry for my english Hope you understand me

2 comments

0

Bruh i was going to answer it :(

0

XD

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