SERVER SCRIPT
local Users = game:GetService("Players") Users.PlayerAdded:Connect(function(User) local Char = User.Character or User.CharacterAdded:Wait() local Head = Char:WaitForChild("Head") for _, Tag in ipairs(script:GetChildren()) do -- the tags are the children of the script. local Clone = Tag:Clone() Clone.Parent = Head Clone.Adornee = Head end end)
I want to ask because I've recently gained a lot of knowledge and would like to know if there is any better way to optimise/make this script more efficient. Please provide an answer if possible, thank you! <3
Well, you made a mistake in your script. It will add overhead guis once, but no more. You can test it. To make it work, you need to listen for another event Player.CharacterAdded
:
local Users = game:GetService("Players") Users.PlayerAdded:Connect(function(User) User.CharacterAdded:Connect(function(Char) -- do your thing end) end)
I personally prefer to move such scripts into a StarterPlayer.StarterCharacterScripts
to clean other folders from scripts, but I am not sure if it's the most efficient way, but doing so you don't need to bother about listening to events and cloning things.