Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Is this one of/the most optimal ways to add multiple overhead guis to a user's head?

Asked by
Antelear 185
3 years ago

SERVER SCRIPT

01local Users = game:GetService("Players")
02 
03Users.PlayerAdded:Connect(function(User)
04    local Char = User.Character or User.CharacterAdded:Wait()
05    local Head = Char:WaitForChild("Head")
06 
07    for _, Tag in ipairs(script:GetChildren()) do -- the tags are the children of the script.
08        local Clone = Tag:Clone()
09        Clone.Parent = Head
10        Clone.Adornee = Head
11    end
12end)

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

0
Is it a billboard gui? And where is this script located? MrSuperKrut 167 — 3y
0
Billboard gui, and it's not "A", i said MULTIPLE. there is MULTIPLE overhead guis. that's why i'm using an ipairs loop. Antelear 185 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

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:

1local Users = game:GetService("Players")
2 
3Users.PlayerAdded:Connect(function(User)
4    User.CharacterAdded:Connect(function(Char)
5        -- do your thing
6    end)
7end)

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.

0
I specifically want it in the serverscriptservice, that's it generally. and omg thank you if i did not notice that...sdfjkhgshjsdga Antelear 185 — 3y
Ad

Answer this question