I’m currently trying to make a kill feed. After researching around on how to do Custom UI List Layouts (without actually using UIListLayout cause it’s not that great) so that I could animate stuff for it. I managed to get through the first couple of steps, however I’m stumbled upon trying to remove a single object, it’s getting the reference but it’s removing all of them if it counts up to 8. I’ve diagnosed it using prints and trying to figure out where it’s going wrong, but I couldn’t wrap my head around it. My guess is that object.removedReq
isn’t being called at all.
Not only that, how do I keep the position of an object right without all the messy inaccurate decimals? I’ve had it to where the object.pos
was the frame itself and then I could use that to do the math, which kept it accurate however I had to change it so that I could actually remove the object later.
local TweenService = game:GetService("TweenService")
local button = script.Parent.Parent.TextButton
local Frame = script.ClonedFrame
local FillFrame = script.Parent.FillFrame
local names = {"One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine", "Ten"}
local masterUI = {}
local function removeObj(object)
if not object.removedReq then
object.removedReq = true
local animation = TweenService:Create(object.obj, TweenInfo.new(0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.Out), {Position = UDim2.fromScale(1, object.obj.Position.Y.Scale)})
animation:Play()
animation.Completed:Connect(function()
object.obj:Destroy()
table.remove(masterUI, object.pos)
updateAll()
end)
end
end
local function getPos(pos)
print(pos)
print(masterUI[pos].obj.Position.Y.Scale)
return UDim2.fromScale(0, masterUI[pos].obj.Position.Y.Scale - 0.09)
end
function updateAll()
for pos, object in masterUI do
object.pos = pos
game:GetService("TweenService"):Create( object.obj, TweenInfo.new(1, Enum.EasingStyle.Exponential, Enum.EasingDirection.Out), {Position = getPos(pos) } ):Play()
if #masterUI > 7 and not object.removedReq then
task.spawn(removeObj, object)
end
end
end
local function createObject()
local ClonedFrame = Frame:Clone()
ClonedFrame.Position = UDim2.fromScale(0, 1.004)
ClonedFrame.Parent = FillFrame
ClonedFrame.Stuff.TextLabel.Text = names[math.random(1, #names)] .. " killed " .. names[math.random(1, #names)]
local object = {
obj = ClonedFrame,
pos = 0,
}
table.insert(masterUI, 1, object)
updateAll()
end
button.MouseButton1Down:Connect(function()
createObject()
end)