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

New player joins and he can't see the other peoples textlabels that joined before him?

Asked by 5 years ago
Edited 5 years ago

Ok, let me explain my script, basically when a player joins it should clone the frame to everyone's Player GUI which it does. Let me make it easy to understand P1 = first person that joined the game P2 = seconds person that joined the game so when P1 joins he can see his text label and everything there, However when P2 joins he can see his but he can't see P1's text label, but P1 can see both His and P2's text labels.

Here are some pictures: !
https://gyazo.com/d14a4d69012dda6a513b53024939690f so here as you see player 1 joins first and he can see the next player that joins, However; !
https://gyazo.com/75edfacf9fb7c5a3688868e410d79fc9 when player 2 joins after player 1 he cant see player 1's text label.

Server Script:

game.Players.PlayerAdded:Connect(function(player)
    local NewFolder = Instance.new("Folder")
    NewFolder.Name = player.Name
    NewFolder.Parent = game.Workspace:WaitForChild("Stat")
    local PointsValue = Instance.new("NumberValue")
    PointsValue.Value = 0
    PointsValue.Parent = NewFolder
    PointsValue.Name = "Points"
    local AssistsValue = Instance.new("NumberValue")
    AssistsValue.Value = 0
    AssistsValue.Parent = NewFolder
    AssistsValue.Name = "Assists"
    local ReboundsValue = Instance.new("NumberValue")
    ReboundsValue.Value = 0
    ReboundsValue.Parent = NewFolder
    ReboundsValue.Name = "Rebounds"
    local StealsValue = Instance.new("NumberValue")
    StealsValue.Value = 0
    StealsValue.Parent = NewFolder
    StealsValue.Name = "Steals"
    local BlockValue = Instance.new("NumberValue")
    BlockValue.Value = 0
    BlockValue.Parent = NewFolder
    BlockValue.Name = "Blocks"
    game.ReplicatedStorage:WaitForChild("NameStat"):FireAllClients(player.Name)
end)

LOCAL SCRIPT

local replicated = game:GetService("ReplicatedStorage")



replicated:WaitForChild("NameStat").OnClientEvent:Connect(function(name)

    local frame = script.Parent.StatsClone.PlayerStats

    local frameclone = frame:Clone()

    frameclone.Parent = script.Parent.Home

    frameclone.Visible = true

    frameclone:WaitForChild("PlayerName").Text = name

for i,v in pairs(game.Players:GetPlayers()) do

    if v then

    local playergui = v.PlayerGui

    local Frames = playergui:WaitForChild("StatSheet").Main.Home:GetChildren()

    Frames:Destroy()

    frameclone.Parent = playergui.Main.Home

    frameclone.Visible = true

    frameclone:WaitForChild("PlayerName").Text = v.Nameo

        end

    end

end)
0
can u send an image of the gui?? NickAtNick 163 — 5y
0
k hold up WillBe_Stoped 71 — 5y
0
The reason it isnt working is cause you're creating it clientside and you're trying to access other player's PlayerGui which you cannot do clientside,so just do it all from the server. OrangeDoggoo 0 — 5y
0
hmm how would i do it? i need to clone the frame and then what do i do? WillBe_Stoped 71 — 5y
View all comments (6 more)
0
You need to drop the cloning code into the PlayerAdded part. OrangeDoggoo 0 — 5y
0
hmm how would i access the frame from the server script? WillBe_Stoped 71 — 5y
0
same way you access it from client. OrangeDoggoo 0 — 5y
0
maybe it would work if you were to create an update() function. but is ur line 31 suppose to be Nameo NickAtNick 163 — 5y
0
o wait no it wasnt WillBe_Stoped 71 — 5y
0
well, did it work now? but p1's gui is working fine. so maybe that isnt the case. NickAtNick 163 — 5y

Answer this question