Change team
Key RequiredUniversal

Change team

Universal Scriptanyara1919anyara1919 10.8K views 90 executesUpdated May 21, 2024
2.5/ 5(2 votes)
1150% Positive
Lua Script•48 lines (1483 chars)
-- รายชื่อทีมที่สามารถเปลี่ยนได้
local teams = {
    ["Red"] = "Red Team",
    ["Blue"] = "Blue Team",
    ["Green"] = "Green Team",
    ["Yellow"] = "Yellow Team"
}

-- ฟังก์ชันเปลี่ยนทีม
local function changeTeam(player, teamName)
    local team = game.Teams:FindFirstChild(teamName)
    if team then
        player.Team = team
        player:LoadCharacter()  -- รีเซ็ตตัวละครเพื่อเปลี่ยนทีมทันที
        player:FindFirstChildOfClass("PlayerGui"):SetCore("ChatMakeSystemMessage", {
            Text = "You have been switched to " .. teamName;
            Color = Color3.new(0, 1, 0);
        })
    else
        player:FindFirstChildOfClass("PlayerGui"):SetCore("ChatMakeSystemMessage", {
            Text = "Invalid team name!";
            Color = Color3.new(1, 0, 0);
        })
    end
end

-- ฟังก์ชันดำเนินการเมื่อผู้เล่นพิมพ์ในแชท
local function onChatted(player, message)
    local args = string.split(message, " ")
    if args[1] == "/team" and args[2] then
        local teamName = teams[args[2]]
        if teamName then
            changeTeam(player, teamName)
        else
            player:FindFirstChildOfClass("PlayerGui"):SetCore("ChatMakeSystemMessage", {
                Text = "Invalid team name!";
                Color = Color3.new(1, 0, 0);
            })
        end
    end
end

-- เชื่อมต่อฟังก์ชันกับเหตุการณ์
game.Players.PlayerAdded:Connect(function(player)
    player.Chatted:Connect(function(message)
        onChatted(player, message)
    end)
end)

Features & Information

The script for changing teams is as follows: 1 Enter the game team name to match the team name and run the script I don't know if it really works, you guys have to try it

Community Comments (0)

No comments yet for this script.

More Scripts for Universal Scripts