i can’t tell whether i’m just doing this wrong, but no matter what i try, it just can’t detect any sort of guiobject (like a frame, or a textlabel) on every single frame
local function ShiftRewardLabelToTop(rewardlabel: TextLabel)
local tweenGoal = {Position = UDim2.fromScale(0, 0)}
local shiftTween = tService:Create(rewardlabel, shiftRewardLabelToTopTweenParams, tweenGoal)
local fadeOutTween = tService:Create(rewardlabel, fadeOutTweenParams, {TextTransparency = 1})
shiftTween:Play()
task.spawn(function()
FlashRewardLabel(rewardlabel)
end)
task.spawn(function()
shiftTween.Completed:Wait()
task.wait(2)
fadeOutTween:Play()
fadeOutTween.Completed:Wait()
rewardlabel:Destroy()
shiftTween:Destroy()
fadeOutTween:Destroy()
end)
while shiftTween.PlaybackState == Enum.PlaybackState.Playing do
local textlabelsAtPosition = plrGui:GetGuiObjectsAtPosition(rewardlabel.Position.X.Scale, rewardlabel.Position.Y.Scale)
print(textlabelsAtPosition) -- gives {} :((
for _, guiObject in textlabelsAtPosition do
if not guiObject:IsA("TextLabel") then continue end
if guiObject.Name ~= "RewardLabel" then continue end
shiftTween.PlaybackState = Enum.PlaybackState.Completed
shiftTween:Cancel()
end
task.wait()
end
end
You’re using the scale values, whereas I believe GetGuiObjectsAtPosition uses pixel offset. You can try to use rewardLabel.AbsolutePosition.X and rewardLabel.AbsolutePosition.Y instead.
What’s the script actually trying to achieve? Is the rewardLabel the “Shombler killed | +25XP…” thing or the “+48”?
You could try running a test script by placing a 1x1 pixel gui somewhere on your screen and running the GetGuiObjectsAtPosition at that position. If that’s working fine, then you know it’s something to do with the positions.
theres probably a much better way to stop them colliding because if ur using the scrollingframe structure i told u about in a different post u can just put a blank frame in to the layout when the new label is created to create a gap and destroy it when u parent the label to the scrollingframe
Try subtracting the rewardlabel’s position with the GuiInset, like so:
local GuiService = game:GetService("GuiService")
local function ShiftRewardLabelToTop(rewardlabel: TextLabel)
local tweenGoal = {Position = UDim2.fromScale(0, 0)}
local shiftTween = tService:Create(rewardlabel, shiftRewardLabelToTopTweenParams, tweenGoal)
local fadeOutTween = tService:Create(rewardlabel, fadeOutTweenParams, {TextTransparency = 1})
shiftTween:Play()
task.spawn(function()
FlashRewardLabel(rewardlabel)
end)
task.spawn(function()
shiftTween.Completed:Wait()
task.wait(2)
fadeOutTween:Play()
fadeOutTween.Completed:Wait()
rewardlabel:Destroy()
shiftTween:Destroy()
fadeOutTween:Destroy()
end)
while shiftTween.PlaybackState == Enum.PlaybackState.Playing do
local position = rewardlabel.AbsolutePosition - GuiService:GetGuiInset()
local textlabelsAtPosition = plrGui:GetGuiObjectsAtPosition(position.X, position.Y)
print(textlabelsAtPosition) -- gives {} :((
for _, guiObject in textlabelsAtPosition do
if not guiObject:IsA("TextLabel") then continue end
if guiObject.Name ~= "RewardLabel" then continue end
shiftTween.PlaybackState = Enum.PlaybackState.Completed
shiftTween:Cancel()
end
task.wait()
end
end
Set up a scrolling frame with a ui list layout so that when u parent a label to it it appears the exact same as if no label was parented to it (visually) so like changing cell size and things (you’ll probably need UIAspectRatioConstraints to size them consistently across devices)
When a new label is to be tweened into position, parent a transparent frame to the ScrollingFrame the same size as the label so it effectively creates a “gap” for the new label to slot in
Tween the new label in
When the tween is done, remove the blank frame and parent the new label to the scrolling frame
this makes it look like you positioned it perfectly into place without having to create your own UIListLayout system
oh wait i just had an idea
can you put the textlabel inside of a frame and tween the text label with positions relative to the frame until it is positioned correctly? that way u can just parent the frame and tween in the textlabel
the tween shouldn’t bypass the gap because if u do the positions correctly then it will look like its slotting right in
This is because it’s set to 1 scale relative to its parent frame, so when we set it to 1 it’s only as big as it’s parent. Of course, if we make it larger, we can make it bigger than the parent, like this:
but the secondary frame is relative in size to its parent, so what im saying is you’ll need to change the sizes of the frame inside the scrolling frame and the label so they’re different if you’re going to use the scale property. Using offset property of UDim2 will make it pixels size, which means you could make them the same but you’ll need to scale them down across devices.
Try storing the rewardlabels inside of a table, which would allow you to offset their positions when a new rewardlabel is created, like so:
local rewardlabels = {}
local rewardlabelOffset = UDim2.fromScale(0, 0.1) -- You'll need to adjust this value according to the rewardlabel's size
local function ShiftRewardLabelsDown()
for rewardlabel in rewardlabels do
rewardlabel.Position += rewardlabelOffset
end
end
local function ShiftRewardLabelToTop(rewardlabel: TextLabel)
task.spawn(ShiftRewardLabelsDown)
local shiftTween = tService:Create(
rewardlabel,
shiftRewardLabelToTopTweenParams,
{Position = UDim2.fromScale(0, 0)})
local fadeOutTween = tService:Create(
rewardlabel,
fadeOutTweenParams,
{TextTransparency = 1})
shiftTween:Play()
rewardlabels[rewardlabel] = true
task.spawn(FlashRewardLabel, rewardlabel)
task.spawn(function()
shiftTween.Completed:Wait()
task.wait(2)
fadeOutTween:Play()
fadeOutTween.Completed:Wait()
rewardlabel:Destroy()
shiftTween:Destroy()
fadeOutTween:Destroy()
rewardlabels[rewardlabel] = nil
end)
end