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

Make an Overhead GUI update to reflect group rank upon respawn?

Asked by 6 years ago

I'm not sure if it's still possible with FE enabled, but this script used to work perfectly fine, but it no longer updates upon re spawning someone. If anyone could help me understand what is wrong here I could really use the help.

Rank Handler: (Assigning the rank)

-- Rank Player Script --

local rs = game:GetService("ReplicatedStorage")
local remotefolder = rs:WaitForChild("RankFolder")
local remote = remotefolder:WaitForChild("RankPlayerOnRespawn")

remote.OnServerEvent:connect(function(Player)
    if not Player then
        print("an error occured fetching the player")
    end
    local pRank = Player:GetRoleInGroup(1031446)
    wait(1)
    local ui = script.Rank:Clone()
    ui.Parent = Player.Character
    ui.Adornee = Player.Character.Head

    while not Player.Character.Humanoid do wait() end
    Player.Character.Humanoid.DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
    local frame = ui.Frame
    local name = frame.Name1
    local role = frame.TextLabel

    name.Text = Player.Name
    role.Text = pRank

end)

System to fire the addition of the rank: (This is located in PlayerGUI so it updates when they respawn)

local rs = game:GetService("ReplicatedStorage")
local remotefolder = rs:WaitForChild("RankFolder")
local remote = remotefolder:WaitForChild("RankPlayerOnRespawn")

remote:FireServer()

Within the ReplicatedStorage - > RankFolder My event is still there, it just seems to be an issue with it picking up the new value. Any help would be greatly appreciated.

1 answer

Log in to vote
0
Answered by 6 years ago

Since it originates from the server, no changes are needed. Let me rewrite the code.

Please use Connect not connect, it's deprecated.

local gui = YOUR GUI HERE:Clone()

game:GetService("Players").PlayerAdded:Connect(function(plr)
    plr.CharacterAdded:Connect(function(char)
        -- Do your rank code here. 
    end)
end)
Ad

Answer this question