I have a GUI which is created in a scrolling frame when a humanoid is cloned into workspace. I don't know how to make it so if more humanoids spawn in, new GUI messages will be created slightly under the one above it.
Here is an example of the concept with the script I have currently. The script only creates the GUI in that specific position I told it to.
https://gyazo.com/811d10f2f96196b7851e3655b13bfd68
Here is the code I used to create the GUI in the example. Don't know if I'll have to create a new script or can use this one.
local myRemoteEvent = game.ReplicatedStorage.RemoteEvent game.Players.PlayerAdded:connect(function(nP) nP.CharacterAdded:connect(function(nC) myRemoteEvent.OnClientEvent:Connect(function() --When the humanoid is cloned TestFrame = Instance.new("Frame", nP.PlayerGui.DispatchGUI.Calls) TestImage = Instance.new("ImageLabel", TestFrame) TestText = Instance.new("TextLabel", TestFrame) --Frame TestFrame.Size = UDim2.new(0,50,0,50) TestFrame.BackgroundTransparency = 1 --Image TestImage.Position = UDim2.new(0,0,0,50) TestImage.Size = UDim2.new(0,300,0,40) TestImage.Image = "rbxassetid://156579757" TestImage.ImageTransparency = 0.8 TestImage.BackgroundColor3 = Color3.new(255/255,191/255,029/255) TestImage.ZIndex = 2 --Text TestText.Position = UDim2.new(0,0,0,50) TestText.Size = UDim2.new(0,300,0,40) TestText.ZIndex = 3 TestText.Font = "SourceSansBold" TestText.Text = "10-31R - BURGLARY" TestText.TextSize = 30 TestText.BackgroundTransparency = 1 TestText.TextColor3 = Color3.new(52/255,52/255,52/255) TestText.TextStrokeTransparency = 1 TestText.TextXAlignment = "Left" end) end) end)
Any help will be useful. Thanks
local myRemoteEvent = game.ReplicatedStorage.RemoteEvent local YIndex = 50 game.Players.PlayerAdded:connect(function(nP) nP.CharacterAdded:connect(function(nC) myRemoteEvent.OnClientEvent:Connect(function() --When the humanoid is cloned local TestFrame = Instance.new("Frame") local TestImage = Instance.new("ImageLabel") local TestText = Instance.new("TextLabel") --Frame TestFrame.Size = UDim2.new(0,50,0,50) TestFrame.BackgroundTransparency = 1 --Image TestImage.Position = UDim2.new(0,0,0,YIndex) TestImage.Size = UDim2.new(0,300,0,40) TestImage.Image = "rbxassetid://156579757" TestImage.ImageTransparency = 0.8 TestImage.BackgroundColor3 = Color3.new(255/255,191/255,029/255) TestImage.ZIndex = 2 --Text TestText.Position = UDim2.new(0,0,0,YIndex) TestText.Size = UDim2.new(0,300,0,40) TestText.ZIndex = 3 TestText.Font = "SourceSansBold" TestText.Text = "10-31R - BURGLARY" TestText.TextSize = 30 TestText.BackgroundTransparency = 1 TestText.TextColor3 = Color3.new(52/255,52/255,52/255) TestText.TextStrokeTransparency = 1 TestText.TextXAlignment = "Left" TestText.Parent = TestFrame TestImage.Parent = TestFrame TestFrame.Parent = nP.PlayerGui.DispatchGUI.Calls YIndex = YIndex + 50 end) end) end)
It is bad etiquette to use the "Parent" argument in "Instance.new()" here's an article on that https://devforum.roblox.com/t/psa-dont-use-instance-new-with-parent-argument/30296 Set the parent of the object after you change the properties
All I did to your code is add a variable called "YIndex". All this variable does is add 50 every time the "CharacterAdded" event is run. This makes the position of the frame go down by 50 pixels each time. I also changed your "TestFrame", "TestImage", "TestText" to local variables, seeing as I'm guessing you won't be using those variables after the "CharacterAdded" event.
I also highly suggest using scale in your "UDim2.new(XScale,XOffset,YScale,YOffset)". I'm suggesting this because when someone with a larger screen or smaller screen tries to play the game, the sizing and positioning will be completely off.
Hope this helps.