Text doesn't continue on mobile because of the size

I Have a problem with my npc dialogue text, I want this to be the same size for every device without having the text cut off, how do I fix that?

Mobile :point_down:

PC :point_down:

2 Likes

Are you using scale or offset? Maybe the problem is because of offset

I am using scale and everything works:

Mobile:

Screenshot 2024-05-21 195547

PC:

1 Like

I’m using scale, can u try making a longer sentence?

1 Like

Give me a moment (Character limit)

1 Like

Still working

Screenshot 2024-05-21 200324

1 Like

Oh
Would you mind taking a look, maybe I did something wrong?

TextProblem.rbxm (6.3 KB)

1 Like

Everything looks good, maybe i can share you script i am using to type dialogue:

local dialogue = require(script.ModuleScript) -- dialogues here
local DummyPP = workspace.T.ProximityPrompt -- promt
local TalkLabel = script.Parent.Talk -- my label

local function TypeDialogue(dialogueText) -- func to type text
	local currentIndex = 0
	local function TypeNextCharacter()
		currentIndex = currentIndex + 1
		TalkLabel.Text = string.sub(dialogueText, 1, currentIndex)
		if currentIndex < #dialogueText then
			wait(0.05)
			TypeNextCharacter()
		end
	end
	TypeNextCharacter()
end

DummyPP.Triggered:Connect(function() -- promt func
	script.Parent.daName.Text = dialogue.DummyDia0.Name
	TypeDialogue(dialogue.DummyDia0.Dialogue.first)
end)
1 Like

Maybe this would help more, Here’s the problem when you talk with the npc

robloxapp-20240521-2109110.wmv (887.9 KB)
robloxapp-20240521-2110111.wmv (1.2 MB)

1 Like

Can you share your script when you are typing the dialogue (not all, just a func), maybe i will understand the problem

1 Like

Also are you using textSize or textScaled? Because if textScaled the are no problems

1 Like
local DialogueGui = script.Parent
local DialogueSequence = DialogueGui:WaitForChild("DialogueSequence")
local Main = DialogueGui:WaitForChild("Main")

local CurrentDialogue = 1

local function typewriterEffect(targetText)
	Main.ContinueFrame.Visible = false  -- Hide the frame and button
	Main.ContinueButton.Visible = false
	Main.DialogueBox.Text = ""
	for i = 1, #targetText do
		Main.DialogueBox.Text = Main.DialogueBox.Text .. string.sub(targetText, i, i)
		wait(0.05)  -- Adjust the speed of the typewriter effect here
	end
	Main.ContinueFrame.Visible = true  -- Show the frame and button after typing
	Main.ContinueButton.Visible = true
end

local function showNextDialogue()
	local TargetDialogue = DialogueSequence:FindFirstChild(CurrentDialogue)

	if TargetDialogue then
		typewriterEffect(TargetDialogue.Value)
		CurrentDialogue = CurrentDialogue + 1

		-- Check if this is the last dialogue
		if CurrentDialogue > #DialogueSequence:GetChildren() then
			Main.ContinueButton.Text = "End"
			-- Change ContinueFrame's UIGradient to switch the colors
			Main.ContinueFrame.UIGradient.Color = ColorSequence.new{
				ColorSequenceKeypoint.new(0, Color3.fromRGB(100, 29, 36)),  -- Top color: 641d24
				ColorSequenceKeypoint.new(1, Color3.fromRGB(232, 65, 95))   -- Bottom color: e8415f
			}
		end
	else
		Main.ContinueButton.Text = "End"
		-- Change ContinueFrame's UIGradient to switch the colors
		Main.ContinueFrame.UIGradient.Color = ColorSequence.new{
			ColorSequenceKeypoint.new(0, Color3.fromRGB(100, 29, 36)),  -- Top color: 641d24
			ColorSequenceKeypoint.new(1, Color3.fromRGB(232, 65, 95))   -- Bottom color: e8415f
		}
	end
end

if DialogueSequence:FindFirstChild(CurrentDialogue) then
	showNextDialogue()
end

local clickedend = false

Main.ContinueButton.MouseButton1Click:Connect(function()
	if Main.ContinueButton.Text == "End" then
		if not clickedend then
			clickedend = true

			game:GetService("TweenService"):Create(Main, TweenInfo.new(1, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut), {Position = UDim2.new(0.302, 0, 2, 0)}):Play()

			wait(1)
			DialogueGui.TargetEvent.Value:FireServer()
		end
	else
		showNextDialogue()
	end
end)

image

I got your error:

Screenshot 2024-05-21 201528

1 Like

yeah I know but when I use it, it changes the size of the text when it types and I’d rather make it the same size

robloxapp-20240521-2118324.wmv (567.5 KB)

1 Like

You can try selecting RichText but…

Screenshot 2024-05-21 202151

That’s not what you need

1 Like

You can try scaling the frame more on mobile devices

1 Like

By using Scale instead of Offset Udim2.new(0.395, 0, 0.227, 0) at that case, you have adjusted the text to fit your screen only.

It also cuts on my screen because it is probably smaller than yours.

What I’ve done was change the size to use Offset; Deleted the UIAspectRatioConstraint since I believe, with a grain of salt, that if you correctly size the UI you shouldn’t need to use it; Enabled the AutomaticSize of the Main frame and the DialogueBox, and did a few minor tweaks.

Hope that helps.
DialogueGui

2 Likes

Thank you so much! I appreciate this :slight_smile:

2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.