Hello, i am making a UI only game called DON’T TOUCH THE BUTTON and i have an issues with some scripts that draw text. There are 2 scripts, the first one is enabled when the player enters the game. It’s a script that animates a text box saying the rules of the game and when it ends it dissapears. the second one appears when the player touches the button for the first time, blaming and threatening the player for touching the button.
The first issue is that the 2 scripts are for the same TextLabel, so if you spam the button, the two lines that the codes display overlap eachother.
And the second issue when the line starts the text becomes visible and when it ends the text becomes insible, it’s the same for the two scripts. so if you click the button mid sentence of the text displaying and changing it for another line, the lines overlap again.
I tried to make the line stop when another is enabled, destroying the script or dissapearing the text but nothing works.
Here are the two scripts:
SCRIPT ONE
local Button = script.Parent.Parent.TextButton
local scripty = game.StarterGui.ScreenGui2.TextLabel.LocalScript
local player = game.Players.LocalPlayer
local function AnimateText(Text)
for i = 1, #Text, 1 do
script.Parent.Text = string.sub(Text, 1 ,i)
wait(0.03)
end
end
while true do
AnimateText("Hello. i am the narrator!")
wait(4)
AnimateText("All you gotta do in this game is to")
wait(2)
AnimateText("NOT TOUCH THE BUTTON")
wait(4)
AnimateText("Have fun!")
wait(0.5)
script.Parent.Visible = false
script.Disabled = true
script:Destroy()
end
if player.WaitForChild("leaderstats").WaitForChild("Clicks").Value >= 1 then
script.Parent.Visible = false
script.Disabled = true
script:Destroy()
end
SCRIPT TWO
local Button = script.Parent.Parent.TextButton
local scripty = script
local player = game.Players.LocalPlayer
Button.MouseButton1Click:Connect(function(hit)
print("buttonTouched")
local function AnimateText(Text)
for i = 1, #Text, 1 do
script.Parent.Text = string.sub(Text, 1 ,i)
wait(0.03)
end
end
while true do
script.Parent.Visible = true
AnimateText("Why did you do that.")
wait(2)
AnimateText("if you do that again i will break you ")
wait(4)
script.Parent.Visible = false
script.Disabled = true
script:Destroy()
end
end)
if player.WaitForChild("leaderstats").WaitForChild("Clicks").Value >= 2 then
script.Parent.Visible = false
script.Disabled = true
script:Destroy()
end
this is how my StarterUi looks like:
And here’s how the game looks like:
I would appreaciate some help!