I decided to write a script without the requested information.
This is a script with some easily use-able functions I wrote in it.
-
The primary function is: newLog(PlayerName1, ImageId, PlayerName2)
.
PlayerName1 is the name of the person who’s featured on the left,
ImageId is the ImageId of the weapon/death cause,
PlayerName2 is the name of the person who’s featured on the right.
-
The secondary function is: updateLog(frame)
.
frame is the frame that contains all the textlabels and the imagelabel that got made with newLog()
.
tip: update the frame with updateLog()
whenever the TextSize get’s changed with TextScaled
Here’s the full script:
--// Config
local screenEdgeOffset = 15 --// The amount of offset the first textlabel has from the screen edge on the left (in pixels)
local offsetSpace = 10 --// in pixels
function updateLog(frame) --// Updates the log to prevent the frames from overlapping
local imageLabel, plr1, plr2 = frame:WaitForChild("Image"), frame:WaitForChild("Player1"), frame:WaitForChild("Player2")
--//// Sizes
--// PlayerName1
plr1.Size = UDim2.new(0, plr1.TextBounds.X + offsetSpace, plr1.Size.Y.Scale, 0)
--// PlayerName2
plr2.Size = UDim2.new(0, plr2.TextBounds.X + offsetSpace, plr2.Size.Y.Scale, 0)
--//// Positions
--// PlayerName1
plr1.Position = UDim2.new(0, screenEdgeOffset, plr1.Position.Y.Scale, 0)
--// ImageLabel
imageLabel.Position = UDim2.new(0, plr1.AbsoluteSize.X + plr1.AbsolutePosition.X, imageLabel.Position.Y.Scale, 0)
--// PlayerName2
plr2.Position = UDim2.new(0, imageLabel.AbsoluteSize.X + imageLabel.AbsolutePosition.X + offsetSpace, plr2.Position.Y.Scale, 0)
--// Frame Size
frame.Size = UDim2.new(0, plr2.AbsolutePosition.X + plr2.AbsoluteSize.X + offsetSpace, frame.Size.Y.Scale, 0)
end
function newLog(PlayerName1, ImageId, PlayerName2) --// PlayerName1 = Killer, ImageId = ImageId of i.e. the weapon, PlayerName2 = Killed
if not PlayerName1 or not PlayerName2 then error"missing names (logKill)" return end --// Ends the function if the names are missing
local frame = script:WaitForChild("Frame"):Clone() --// Making a copy of the template stored in the script
local imageLabel, plr1, plr2 = frame:WaitForChild("Image"), frame:WaitForChild("Player1"), frame:WaitForChild("Player2")
--// Setting properties (text & imageId)
plr1.Text = PlayerName1
plr2.Text = PlayerName2
if ImageId then --// Checks if an ImageId was provided, without this it would've returned an error
imageLabel.Image = ImageId --// For example "rbxassetid://0"
end
frame.Parent = script.Parent --// Whatever parent you wish it to have
updateLog(frame)
end
newLog("D3strat", nil, "ChuckXZ")
And here’s the place file with the script and necessary setup (StarterGui): killLogScript.rbxl (562.2 KB)
If you’ve got any questions whether it’s about the OP question or the script etc., then reply and I’ll get to you as soon as possible.