Hello! I am trying to make a script where if you click something it typewrites it on a GUI!
Unfortunatly, everytime when I load in the game this error pops up and clicking on the button does nothing.
Here is my code and I am really confused and have NO IDEA why it’s appearing when I load in the game and not when I click.
local function typewrite(textlabel,text)
for i = 1, #text do
textlabel.Text = string.sub(text, 1, i)
game.Workspace.textsfx:Play()
wait(0.05)
end
end
local enabled = true
local part = game.Workspace.Tube.Button1.ClickDetector
part.MouseClick:Connect(function(plr)
local textlabel = game.Players.LocalPlayer.PlayerGui.Text.Message
if enabled == true then
local enabled = false
typewrite(textlabel, plr.Name.. ", this is the text that will appear when I click!")
wait(7)
end
end)
Thank you all!