Can you confirm that the TextLabel is really moving to the end? You can do this by having the TextLabel selected while it moves to see if it suddenly resets.
local RunService = game:GetService("RunService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local SEND_REMOTE = ReplicatedStorage:WaitForChild("sendterm")
local gui = script.Parent
local SCROLL_SPEED = 200
local frame = gui:WaitForChild("SignFrame")
local label = frame:WaitForChild("SignText")
local startX, endX = 0, 0
local function initPositions()
local parentWidth = gui.AbsoluteSize.X
local frameWidth = frame.AbsoluteSize.X
startX = parentWidth
endX = -frameWidth
frame.Position = UDim2.fromOffset(startX, 0)
end
if gui.AbsoluteSize.X == 0 then
gui:GetPropertyChangedSignal("AbsoluteSize"):Wait()
end
initPositions()
local function setMessage(msg)
label.Text = tostring(msg or "")
label.TextWrapped = false
label.TextXAlignment = Enum.TextXAlignment.Left
label.AutomaticSize = Enum.AutomaticSize.X
RunService.RenderStepped:Wait()
local parentWidth = gui.AbsoluteSize.X
local frameWidth = frame.AbsoluteSize.X
startX = parentWidth
endX = -frameWidth
frame.Position = UDim2.fromOffset(startX, 0)
end
SEND_REMOTE.OnClientEvent:Connect(setMessage)
RunService.RenderStepped:Connect(function(dt)
local x = frame.Position.X.Offset
x = x - SCROLL_SPEED * dt
if x <= endX then
x = startX
end
frame.Position = UDim2.fromOffset(x, 0)
end)
The issue is that you’re relying on AbsoluteSize. The AbsoluteSize property updates every frame, but never in-between. This means that when you set the text of the label and it resizes, AbsoluteSize won’t be correct until the next frame.
There are two possible solutions for this problem:
Don’t rely on AbsoluteSize; use Size instead.
Wait a frame after updating the label. This means running task.wait().
Nevermind, I just realized your issue seems to be much simpler!
You’re simply not getting the width of the label, but rather the “frame”, which I believe to not be intentional. It seems you just have to change frame.AbsoluteSize.X to label.AbsoluteSize.X.
local function setMessage(msg)
label.Text = tostring(msg or "")
label.TextWrapped = false
label.TextXAlignment = Enum.TextXAlignment.Left
label.AutomaticSize = Enum.AutomaticSize.X
RunService.RenderStepped:Wait()
local parentWidth = gui.AbsoluteSize.X
local frameWidth = frame.AbsoluteSize.X -- should be label, not frame.
startX = parentWidth
endX = -frameWidth
frame.Position = UDim2.fromOffset(startX, 0)
end
Unless the frame is automatically resizing with the label?
Still not working, i just removed the frame because i realized it really had no purpose. I changed it to label, but i guess its still not working right.
i found this script. anything that might fix this problem?
-- SignController
local TweenService = game:GetService("TweenService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local remote = ReplicatedStorage:WaitForChild("SendTerminalMessage")
----------------------------------------------------
-- SIGN REFERENCES
local sign = workspace:WaitForChild("DigitalSign")
local gui = sign:WaitForChild("SurfaceGui")
local label = gui:WaitForChild("ScrollingText")
----------------------------------------------------
-- SETTINGS
local SCROLL_TIME = 5
----------------------------------------------------
local function loopScroll()
while true do
-- place text off-screen LEFT
label.Position = UDim2.fromScale(1.5, 0)
-- tween across to RIGHT
local tween = TweenService:Create(
label,
TweenInfo.new(SCROLL_TIME, Enum.EasingStyle.Linear),
{
Position = UDim2.fromScale(-1.1, 0)
}
)
tween:Play()
tween.Completed:Wait()
-- small delay prevents visual stutter
task.wait(0.05)
end
end
----------------------------------------------------
-- UPDATE TEXT FROM TERMINAL
remote.OnServerEvent:Connect(function(player, message)
label.Text = tostring(message)
end)
----------------------------------------------------
-- START LOOP
task.spawn(loopScroll)