Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

string repeating too slowly?

Asked by
lytew 99
4 years ago

I created a script to show text on the screen when a player touches a part..all so far, the problem is that when the player touches the text it appears very slowly while I programmed to appear every 0.1 seconds, so I need help script:

wait(game.Players.PlayerAdded)
wait(1)
local gui = script.Parent.Parent.PlayerGui.dontsave.TextLabel
local texto = 'não salve creyson'
local player = game:GetService("Players")
local debounce1 = false
local soundclick = 'rbxassetid://1238528678'

function touchtext (hit)

local findplayer = player:GetPlayerFromCharacter(hit.Parent)

if findplayer and findplayer.Character and findplayer.Character:FindFirstChild('Humanoid') then

if debounce1 == false then
debounce1 = true
for i = 1,#texto do
wait(0.1)
gui.Text = string.sub(texto,1,i)
local sounddd = Instance.new("Sound")
    sounddd.Volume = 1
    sounddd.SoundId = soundclick
    sounddd.Parent = script.Parent.Parent.PlayerGui
    sounddd:Play()
    sounddd.Ended:Wait()
    sounddd:Destroy()
end
end
end

if gui.Text == 'não salve creyson' then
    wait(1)
    gui.Text = 'não salve creyson :('
        local soundd = Instance.new("Sound")
    soundd.Volume = 1
    soundd.SoundId = soundclick
    soundd.Parent = script.Parent.Parent.PlayerGui
    soundd:Play()
    soundd.Ended:Wait()
    soundd:Destroy()



end 
end

game.Workspace.lava.Touched:Connect(touchtext)
game.Workspace.lava1.Touched:Connect(touchtext)
game.Workspace.lava2.Touched:Connect(touchtext)
game.Workspace.lava3.Touched:Connect(touchtext)
game.Workspace.lava4.Touched:Connect(touchtext)
game.Workspace.lava5.Touched:Connect(touchtext)
game.Workspace.lava6.Touched:Connect(touchtext)
game.Workspace.lava7.Touched:Connect(touchtext)
game.Workspace.lava8.Touched:Connect(touchtext)
game.Workspace.lava9.Touched:Connect(touchtext)
game.Workspace.lava10.Touched:Connect(touchtext)
game.Workspace.lava11.Touched:Connect(touchtext)

Answer this question