Hey guys, I’m back and I still don’t know how to script. As you know from the title, I have some questions about scripting and gui so here they are:
Can I make animated text without scripting? By animated I mean it looks like it’s typing itself. A good example would be lots of those escape the ___ obbies.
Why doesn’t this script work? It works when I take out the part that kicks players but I need it to kick the player when they click the button. Here’s the script:
local CloseButton = script.Parent.CloseButton
local WinnerGui = script.Parent
CloseButton.MouseButton1Click:Connect(function()
WinnerGui.Enabled = false
CloseButton.MouseButton1Click:Connect(function()
player:Kick(reason)
end)
end)
Typewriter effects have to be scripted. Use the MaxVisibleGrapheme property of the textlabel from 0 to the length of the string. Can tween that value or increment it in a loop.
The code snippet doesn’t work because you’re creating two connections to the same button – create two buttons, or add their code together (the kick and the gui enabled in one function)
Also, to get text to “animate like it’s typing itself”, you would need some scripting. But string.sub is our friend here.
local function animateText(text)
for i = 0, #text do
print(string.sub(text, 0, i))
task.wait(1/20) -- 20 letters a second
end
end
animateText("Example! :D Hi, how are you doing?")
local button = script.Parent
local exampleLabel = button.Parent:FindFirstChild("ExampleLabel")
local function animateText(textLabel, text)
for i = 1, #text do
textLabel.Text = string.sub(text, 0, i)
task.wait(1/25)
end
end
button.Activated:Connect(function()
animateText(exampleLabel, "This is some example text to show xander how to implement this")
end)
Wait, so your saying that the way I wrote it means that they have to click the button twice? Whoops. It doesn’t close though so that’s another problem that still happens.