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

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

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:

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.

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