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

why wont my typewriter update the text value?

Asked by 3 years ago
Edited 3 years ago

so i want to make a typewriter effect and this is the script i have rn

local text = game.ReplicatedStorage.ChatText.Value

script.Parent.Parent.ChatText.Chat.MouseButton1Click:Connect(function()
    for i = 1, #text do
        script.Parent.TextLabel.Text = string.sub(text, 1, i)
        wait(0.04)
    end
end)

but when i change the value then it changes to what it was set before i ran the game and it would never update the value

im not sure what im doing wrong here, can someone help me?

1 answer

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

You statically reserved the state of the StringValue Object on line 1. You likely think you've made a pointer to the Value property, but that's not what has occurred in this logic, nor could it ever regardless. Simply allocate the StringValue, then refer to it's value within the scope of your callback:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Text = ReplicatedStorage:WaitForChild("ChatText")
--// This is vulnerable to exploitation.

local function Typewrite()
    local TypewriteString = Text.Value
    ---------------
    for SubstringIndex = 1, #TypewriteString do
        ---------------
        TextLabel.Text = TypewriteString:sub(1, #SubstringIndex)
        ---------------
        wait(.04)
    end
end


Chat.MouseButton1Click:Connect(Typewrite)
0
my output says: 22:22:22.913 - Players.mynam3with123.PlayerGui.ScreenGui.ShowText.LocalScript:9: attempt to get length of a number value and im not sure what it means by that mynam3with123 65 — 3y
0
That means your intended StringValue Object was mistakenly replaced by a NumberValue Instance. Ziffixture 6913 — 3y
Ad

Answer this question