Error On Dialog Script

Hello, Im currently making a story game, and I’ve just made the dialog script, but I’ve got an error,
I’ve got two scripts, a Main one in ServerScriptService, and a local script in my Dialog Gui
Here is the Script in ServerscriptService
–Theduedcow

    DefaultMessageDelayTime = 4
    LetterInterval = 0.05
    MessageWaitSigns = {',', '?', '.'}
    MessageWaitSignDelay = 1
    MessageValue = game.ReplicatedStorage.Message
    ImageValue = game.ReplicatedStorage.Message.SpeakerImage
    SpeakerNameValue = game.ReplicatedStorage.Message.SpeakerName

    --Setup Player Images

    PlayerImages = {}

    PlayerService = game:GetService('Players')
    function MakePlayerImage(Player)
	    local Image = ''
	    local Success,Error = pcall(function()
		    local ID = PlayerService:GetUserIdFromNameAsync(Player.Name) or ''
		    local PlayerImage, IsReady = PlayerService:GetUserThumbnailAsync(ID, 
            Enum.ThumbnailType.AvatarBust, Enum.ThumbnailSize.Size420x420)
		    if IsReady == true  then
			    --Ready to use image
			    Image = tostring(PlayerImage)
		    else
			    --Use Alternative Picture
			    Image = ("http://www.roblox.com/Thumbs/Avatar.ashx? 
                            x=100&y=100&Format=Png&username=%s"):format(Player.Name)
		           end
	               end)
	    if Success == true then
		    --Successful
	    else
		    Image = ("http://www.roblox.com/Thumbs/Avatar.ashx? 
                     x=100&y=100&Format=Png&username=%s"):format(Player.Name)
	            end
	            PlayerImages[Player.Name] = Image
             end


          game.Players.PlayerAdded:Connect(function(Player)
	    MakePlayerImage(Player)
           end)
    for _, Player in pairs(game.Players:GetChildren()) do
	    MakePlayerImage(Player) --This cause studio doesnt rlly activate player added event on 
    testing
        end

    --Functions

    function BroadcastMessage(Text, MessageDelayTime)
	    -- This makes the message appear like a type writer
	    for i = 1,#Text do
		    MessageValue = string.sub(Text,1,i)
		    for _, L in pairs(MessageWaitSigns) do
			    if string.sub(Text,i,i) == L then
				    wait(MessageWaitSignDelay)
			   end
		   end
		
		    wait(LetterInterval)
	    end
	    if tonumber(MessageDelayTime) ~= nil then
		    wait(MessageDelayTime)
	    else
		    wait(DefaultMessageDelayTime)
	    end
	     MessageValue.Value = 'None'
	    return true
    end

    function SetMessageSpeaker(Name)
	    if Name == 'Random' then
	local RandomPlayer = game.Players:GetChildren()[math.random(1#game.Players:GetChildren())]
		    Name = RandomPlayer.Name
	    end
	    ImageValue.Value = PlayerImages[Name] or ''
	    SpeakerNameValue.Value = Name
    end




      -------------------- MAIN SCRIPT OF STORY -------------------

    wait(10)

    SetMessageSpeaker('Random')

    BroadcastMessage('Hello, I am testing if this works...')

This is the local script in the Dialog Gui, in StarterGui

    Message = game.ReplicatedStorage:WaitForChild('Message')

    Speaker = Message:WaitForChild('SpeakerName')

    Image = Message:WaitForChild('SpeakerImage')

    Message:GetPropertyChangedSignal('Value'):Connect(function()

    if Message.Value == 'None' then

    script.Parent.Frame.Visible = false

    else

    script.Parent.Frame.Visible = true

    end

    script.Parent.Frame.Message.Text = Message.Value

    end)

    Speaker:GetPropertyChangedSignal('Value'):Connect(function()

    script.Parent.Frame.ImageLabel.Image = Image.Value

    script.Parent.Frame.Message.Text = Speaker.Value

    end) ```

Here is the error:

![Screenshot_5|549x27](upload://7FIoyAvZse6tCP01ZYmteZM9pP1.png)
2 Likes

You accidentally defined MessageValue as a string, I believe you meant to write:

MessageValue.Value = string.sub(Text, 1, i)
2 Likes

Yes, Thank you… It works now…

3 Likes