Перейти к содержимому

How to Give Players Tools Based on Their Team! | Roblox Studio

Roblox-coding

0:00 / 0:00

How to Give Players Tools Based on Their Team! | Roblox Studio

31 просмотр · 3 дн. назад
Roblox-coding
5 подписчиков
31 просмотр · 3 дн. назад
Here is the script!!! local Players = game:GetService("Players") local ServerStorage = game:GetService("ServerStorage") local TEAM_NAME = "RedTeam" local TOOL_NAME = "DemoTool" local toolTemplate = ServerStorage:WaitForChild(TOOL_NAME) local function removeTool(container) if not container then return end local tool = container:FindFirstChild(TOOL_NAME) if tool then tool:Destroy() end end local function updateTools(player) local backpack = player:WaitForChild("Backpack") local character = player.Character local isCorrectTeam = player.Team and player.Team.Name == TEAM_NAME if isCorrectTeam then if not backpack:FindFirstChild(TOOL_NAME) and not (character and character:FindFirstChild(TOOL_NAME)) then local newTool = toolTemplate:Clone() newTool.Parent = backpack end else removeTool(backpack) removeTool(character) end end local function setupPlayer(player) player:GetPropertyChangedSignal("Team"):Connect(function() updateTools(player) end) player.CharacterAdded:Connect(function() task.wait(0.2) updateTools(player) end) updateTools(player) end Players.PlayerAdded:Connect(setupPlayer) for _, player in ipairs(Players:GetPlayers()) do task.spawn(setupPlayer, player) end