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

Local Server not executing scripts for all players, my fault or Roblox's?

Asked by 5 years ago
Edited 5 years ago

For some reason when I start a Local Server with 4 players, the scripts only seem to work for Player1, Player2, and Player3. Is this an error on my end or on Roblox's end?

I have a custom leaderboard set up and working for Player1, 2, and 3 but it doesn't show any names for Player4.

Below are both scripts that could've caused this somehow.

Server Side

game.ReplicatedStorage.REPlayerJoining.OnServerEvent:Connect(function(playerJ)
    if playerJ.PHBS then else
        local playerfolder = Instance.new("Folder", playerJ)
        playerfolder.Name = "Statistics"
        --
        local timeplayed = Instance.new("NumberValue", playerJ)
        timeplayed.Name = "TimePlayed"
        local timeplayedscript = script.TimePlayedScript:Clone()
        timeplayedscript.Parent = timeplayed
        timeplayedscript.Disabled = false
        --
        local phbs = Instance.new("IntValue")
        phbs.Name = "PHBS"
        phbs.Parent = playerJ
    end
end)

Client Side

game.Players.PlayerAdded:Connect(function(playerJ)
    for i,v in pairs(playersframe:GetChildren()) do
        if v:IsA("TextButton") then
            v:Destroy()
        end
    end
    for i,v in pairs(game.Players:GetChildren()) do
        local ptclone = game.ReplicatedStorage.PlayerTemplate:Clone()
        ptclone.Name = v.Name
        ptclone.PlayerName.Text = v.Name
        ptclone.Parent = playersframe
    end
    --
    game.ReplicatedStorage.REPlayerJoining:FireServer()
end)

game.Players.PlayerRemoving:Connect(function(playerL)
    playersframe[playerL.Name]:Destroy()
    --
    game.ReplicatedStorage.REPlayerLeaving:FireServer()
end)
0
There is little to nothing we can do to help without any scripts. Please post the code so we can assist you further. YabaDabaD0O 505 — 5y

1 answer

Log in to vote
0
Answered by 5 years ago
Edited 5 years ago

Player 1, 2, and 3 would need to rejoin for their names because you only used a PlayerAdded event to add names and never include names of players actually there without someone else joining. You can easily loop through all the players to add their names like

for _, plr in pairs(game.Players:GetPlayers()) do
        local ptclone = game.ReplicatedStorage.PlayerTemplate:Clone()
        ptclone.Name = v.Name
        ptclone.PlayerName.Text = v.Name
        ptclone.Parent = playersframe
end

and your fixed function for PlayerAdded

game.Players.PlayerAdded:Connect(function(playerJ)
        --just adding frames would be fine enough instead of redoing it completely 
        local ptclone = game.ReplicatedStorage.PlayerTemplate:Clone()
        ptclone.Name = playerJ.Name
        ptclone.PlayerName.Text = playerJ.Name
        ptclone.Parent = playersframe

         --handle playeradded events on the server for leaderboard!
end)

Hope this helps!

Ad

Answer this question