
KeylessUniversal

-- รายชื่อทีมที่สามารถเปลี่ยนได้
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)No comments yet for this script.



