I’m trying to get a TextLabel to move if another TextLabel is in the same position as it. This is so I can have multiple texts at once and use a Remote Event to create text without any problems. This script I made works but does not move the TextLabel after the first time. This makes newer TextLabels (that are cloned) overlap each other when they move up for the first time. I tried to constantly check if they were overlapping, but this made them infinitely move up. I have also tried to use a ChildAdded event to check every time a new TextLabel gets added, but this doesn’t work either (same problem).
Picture of how it looks like:
:
My problem:
local function createText(color)
--Clone a template TextLabel
local TextLabel = script.Parent.TextLabel:Clone()
local OriginalTextLabel = script.Parent.TextLabel
--Check for other TextLabels
for i,v in pairs(script.Parent:GetChildren())do
if v:IsA("TextLabel") then
--If there is a different textlabel, tween up
if v ~= OriginalTextLabel then
local tweenpos = TextLabel.Position - UDim2.new(0,0,0.08,0)
local Tween = game:GetService("TweenService"):Create(v,TweenInfo.new(.5),{Position = tweenpos})
Tween:Play()
end
end
end
TextLabel.Parent = script.Parent
TextLabel.Name = "Message"
TextLabel.TextTransparency = 0
TextLabel.TextColor3 = color
return TextLabel
end
MessageEvent.OnClientEvent:Connect(function(message, color)
local text = ""
--Call function to move the text if any are there
local TextLabel = createText(color)
--Scrolling text
for i = 1,#message,1 do
text = message:sub(1,i)
TextLabel.Text = text
wait()
end
wait(3)
--Fade text away and get rid of it
local tweeninfo = TweenInfo.new(.5,Enum.EasingStyle.Linear,Enum.EasingDirection.Out,0,false,0)
local goal = {}
goal.TextTransparency = 1
local fadeTween = TS:Create(TextLabel, tweeninfo, goal)
fadeTween:Play()
fadeTween.Completed:Wait()
TextLabel:Destroy()
end)
If anyone responds to this, thanks!