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

Match an IntValue with a Player's Name?

Asked by 6 years ago

I'm trying to make it so that the values inside the workspace will correlate or match the player's name. It's for multiple people though, and it hasn't been working for me.

--Local Script Inside StarterGUI

local values = workspace.Values
players = values:WaitForChild("Players")
local team1 = players:WaitForChild("Team1")
local team2 = players:WaitForChild("Team2")

local player = game.Players.LocalPlayer
local char = player.Character or player.CharacterAdded:wait()

local teamcaps = values:WaitForChild("Begin")
local teamcap1 = teamcaps:WaitForChild("teamcap1")
local teamcap2 = teamcaps:WaitForChild("teamcap2")

gui = game:WaitForChild("StarterGui")

wait(1)

if player:FindFirstChild("inhere") then
    wait()
else
    local d = Instance.new("ObjectValue")
    d.Parent = player
    d.Name = "inhere"
    local s = Instance.new("NumberValue")
    s.Parent = player
    s.Name = "playernumber"
    gui.Values:Clone().Parent = player
    gui.Stats:Clone().Parent = player
    wait()
    if team1:FindFirstChild("Player1").Value~="" then
        if team1:FindFirstChild("Player2").Value~="" then
            if team1:FindFirstChild("Player3").Value~="" then
                if team1:FindFirstChild("Player4").Value~="" then
                    wait(1)
                else
                    team1:FindFirstChild("Player1").Value = player.Name
                    player:FindFirstChild("playernumber").Value = 1
                    teamcap1.Value = player.Name
                end
            else
                team1:FindFirstChild("Player2").Value = player.Name
                player:FindFirstChild("playernumber").Value = 2
            end
        else
            team1:FindFirstChild("Player3").Value = player.Name
            player:FindFirstChild("playernumber").Value = 3
        end
    else
        team1:FindFirstChild("Player4").Value = player.Name
        player:FindFirstChild("playernumber").Value = 4
    end
    if team2:FindFirstChild("Player1").Value~="" then
        if team1:FindFirstChild("Player2").Value~="" then
            if team1:FindFirstChild("Player3").Value~="" then
                if team1:FindFirstChild("Player4").Value~="" then
                wait(1)
                else
                    team2:FindFirstChild("Player1").Value = player.Name
                    player:FindFirstChild("playernumber").Value = 1
                    teamcap2.Value = player.Name
                end
            else
                team2:FindFirstChild("Player2").Value = player.Name
                player:FindFirstChild("playernumber").Value = 2
            end
        else
            team2:FindFirstChild("Player3").Value = player.Name
            player:FindFirstChild("playernumber").Value = 3
        end
    else
        team2:FindFirstChild("Player4").Value = player.Name
        player:FindFirstChild("playernumber").Value = 4
    end         
end

Idk if it should be WaitForChild or something

--Inside these Values (Workspace - ServerSide)

model=script.Parent

while true do
    wait(0.2)
    if game.Players:FindFirstChild(model.Value) then
        wait()
    else
        model.Value=""
    end
end

This is copied within each value for each player.

Thanks for helping,

LukeGabrieI

1
wait a sec.. is it for the player that joined the game or Player1 Player2 Player3 Player4 Only? greatneil80 2647 — 6y
0
so it's for the player the joined the game. once it reaches 8 players all spots should be full. LukeGabrieI 73 — 6y
0
lemme rephrase it's for each and every player that joins the game. LukeGabrieI 73 — 6y

Answer this question