Im trying to make a tool that pull up a gui, which is working but when i try use the typewriting effect, it works the first time but then it stays as done and not redoing it i used alvinblox’s script as i’m a very new beginner.
local TextLable = script.Parent:WaitForChild("Main"):WaitForChild("Text")
local player = game.Players.LocalPlayer
local Frame = player.PlayerGui.EatFruitGui.Main
local Yes = Frame.Yes
local No = Frame.No
local TypeSound = script.TypingSound
local function TypeWriteEffect(object,text)
for i = 1,#text,1 do
object.Text = string.sub(text,1,i)
TypeSound:Play()
wait(0.05)
end
end
repeat
if Frame.Visible == true then
end
task.wait()
until Frame.Visible == true
TypeWriteEffect(TextLable,"Do You Want To Eat This Fruit?")
local TextLable = script.Parent:WaitForChild("Main"):WaitForChild("Text")
local player = game.Players.LocalPlayer
local Frame = player.PlayerGui.EatFruitGui.Main
local Yes = Frame.Yes
local No = Frame.No
local TypeSound = script.TypingSound
local function TypeWriteEffect(object,text)
for i = 1,#text,1 do
object.Text = string.sub(text,1,i)
TypeSound:Play()
wait(0.05)
end
end
Frame:GetPropertyChangedSignal("Visible"):Connect(function()
TypeWriteEffect(TextLable,"Do You Want To Eat This Fruit?")
end)
Its playing Even tho i clicked no. Im tryna make it so if you click no then click on the tool again it will play the text is playing even tho the gui is not open.
Oh for the tool as well? ok.
‘’’
local Player = game.Players.LocalPlayer
repeat task.wait() until Player.Character
local character = Player.Character or Player.CharacterAdded:Wait()
local humanoid = character:WaitForChild(“Humanoid”)
local Frame = Player.PlayerGui.EatFruitGui.Main
local Yes = Frame.Yes
local No = Frame.No
local EatAnim = script:WaitForChild(“Eat”)
local EatAnimTrack = humanoid.Animator:LoadAnimation(EatAnim)
local DevilFruits = game.ReplicatedStorage.DevilFruits
local currentTool = script.Parent
local Toolname = “Rubber”
local function GiveTool(Player)
Frame.Visible = true
local character = currentTool.Parent
local playerWhoEquippedTool = game.Players:GetPlayerFromCharacter(character)
Yes.MouseButton1Click:wait()
EatAnimTrack:Play()
humanoid.WalkSpeed = 0
wait(3.5)
script.Parent:Destroy()
if not playerWhoEquippedTool.Backpack:FindFirstChild(Toolname) then
local Tool = game.ReplicatedStorage.DevilFruits[Toolname]:clone()
Tool.Parent = playerWhoEquippedTool.Backpack
humanoid.WalkSpeed = 16
else
No.MouseButton1Click:wait()
end
end
currentTool.Activated:Connect(GiveTool)
‘’’
Just for future reference, an even easier way to do this would be through the MaxVisibleGraphemes property. This property allows you to control how many characters are displayed. A primary use case for it is specifically typewriting effects.
Can you use sound with it? also Ive found the fix the new code is
local TextLable = script.Parent:WaitForChild("Main"):WaitForChild("Text")
local player = game.Players.LocalPlayer
local Frame = player.PlayerGui.EatFruitGui.Main
local Yes = Frame.Yes
local No = Frame.No
local TypeSound = script.TypingSound
local DevilFruit = game.StarterPack["Gomu Gomu No Mi"]
local function TypeWriteEffect(object,text)
for i = 1,#text,1 do
object.Text = string.sub(text,1,i)
TypeSound:Play()
wait(0.05)
end
end
repeat
repeat
TypeWriteEffect(TextLable,"")
if Frame.Visible == true then
end
task.wait()
until Frame.Visible == true
TypeWriteEffect(TextLable,"Do You Want To Eat This Fruit?")
task.wait()
No.MouseButton1Click:wait()
until DevilFruit == nil
:D
Yes, this is simply just another property like Text is a property. Sounds and anything else is completely irrelevant.
You can use it in your TypeWriteEffect function like so:
local function TypeWriteEffect(object,text)
-- Set new label text
object.Text = text
-- Loop through the number of characters in the text
for i=1, #text do
object.MaxVisibleGraphites = i
TypeSound:Play()
task.wait(0.05)
end
end
For a more in-depth tutorial on typewriter effects, check out the UI Animations tutorial on the Developer Hub.