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

Typewriter effect running on click event?

Asked by 5 years ago

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!

0
whats the problem? this looks like it would work. Benbebop 1049 — 5y

1 answer

Log in to vote
0
Answered by
Ziffixture 6913 Moderation Voter Community Moderator
5 years ago

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)
0
Would that be for the entire thing or only the area in which the event script is triggered? JackTheGamer44666 18 — 5y
Ad

Answer this question