I'm right now trying to create a typewriter effect based on a click event in my test roblox game.
I've got the click event pinned down, But I need to know how I can get a typewriter effect working once I click something.
Here is the code I'm using
local clickdetector = script.Parent:WaitForChild("ClickDetector") clickdetector.MouseClick:Connect(function() game.StarterGui.Typewritertext.TalkingText.Text = "This is simply, a test." for i = 1, #text do script.Parent.Parent.Dialog.TextLabel.Text = string.sub(text, 1, i) wait(0.04) end end)
Thank you!
The issue is that you’re referencing StarterGui
, a replication container. This is used to form the UI on the server, however, it doesn’t actually belong to the UI that appears in-game. All of it’s content is replicated over to a container in the Player called PlayerGui
. To modify the UI, you must control it from that point of reference.
Try this:
local Players = game:GetService("Players") local ClickDetector = script.Parent:WaitForChild("ClickDetector") Players.PlayerAdded:Connect(function(Player) local PlayerGui = Player:WaitForChild("PlayerGui") ClickDetector.MouseClick:Connect(function() --// From this point use PlayerGui.Typewritertext end) end)