Whenever a player joins, I want buttons to spawn if the player is in a particular group with a specific rank that can put them on a team.
The buttons won’t spawn. I got values set in a table.
Module Script
local teams = {
– {TEAM-NAME,TEAM-COLOR,GROUP-ID,TOOLS,GUI’s}
{“Citizen”,“Medium red”,5387760,{},{}}
}
local specialteams = {
– {TEAM-NAME,TEAM-COLOR,GROUP-ID,GROUP-RANK,TOOLS,GUI’s}
{“President”,“Medium red”,5387760, 20,{},{}}
}
local developers = {“NotABrad”,“JxcobMattis”}
–[[
DO NOT EDIT BELOW THIS POINT.
–]]
local Players = game:GetService(“Players”)
local player = Players.LocalPlayer
local teamEvent = game.ReplicatedStorage.ApplyTeam
local Id = 5387760
if player:GetRoleInGroup(teams[3]) > 1 then
local teambtn = Instance.new(“TextButton”)
local team = Instance.new(“Team”)
– TEAM BTN
teambtn.Text = teams[1]
teambtn.BackgroundTransparency = “0.7”
teambtn.Size = UDim2.new(0, 72, 0, 18)
teambtn.Font = “SourceSansBold”
teambtn.TextColor3 = Color3.new(255, 255, 255)
teambtn.TextScaled = true
teambtn.Parent = player.PlayerGui.StartGui.Teams
teambtn.BackgroundColor3 = Color3.new((math.random()), (math.random()),( math.random()))
teambtn.MouseButton1Click:Connect(function()
team.Name = teams[1]
team.TeamColor = BrickColor.new("Storm blue")
player.plrStats.TeamId = teams[3]
teamEvent:FireServer(team.Name, team.TeamColor, Id)
end)
end
return teams
Script
local DataStoreService = game:GetService(“DataStoreService”)
local plrDataStore = DataStoreService:GetDataStore(“plrDataStore”)
local nickEvent = game:GetService(“ReplicatedStorage”):WaitForChild(“ApplyNick”)
local Players = game:GetService(“Players”)
local billboardgui = game:GetService(“ServerStorage”):WaitForChild(“RankGui”)
game.Players.PlayerAdded:Connect(function(player)
local plrStats = Instance.new(“Folder”)
plrStats.Name = “plrStats”
plrStats.Parent = player
local rpName = Instance.new("StringValue")
rpName.Name = "rpName"
rpName.Parent = plrStats
local teamId = Instance.new("StringValue")
teamId.Name = "TeamId"
teamId.Parent = plrStats
local playerID = player.UserId.."#user"
local data
local success, errormessage = pcall(function()
data = plrDataStore:GetAsync(playerID)
end)
if success then
rpName.Value = data
player.CharacterAdded:Connect(function(char)
local clonedgui = billboardgui:Clone()
clonedgui.Parent = game.Workspace:WaitForChild(player.Name).Head
clonedgui.Frame.NICKNAME.Text = player.plrStats.rpName.Value .. " - " .. player.UserId
if player.plrStats.TeamId.Value == "0" then
clonedgui.Frame.RANK.Text = "Visitor"
else
clonedgui.Frame.RANK.Text = player:GetRoleInGroup(player.plrStats.TeamId.Value)
end
end)
end
end)
game.Players.PlayerRemoving:Connect(function(player)
local playerID = player.UserId…“#user”
local data = player.plrStats.rpName.Value
local success, errormessage = pcall(function()
plrDataStore:SetAsync(playerID, data)
end)
if success then
print(player.UserId.."'s Data saved!")
else
print("Error saving"..player.UserId.."'s Data")
warn(errormessage)
end
end)
nickEvent.OnServerEvent:Connect(function(plr,text)
local filteredNick = game:GetService(“Chat”):FilterStringForBroadcast(text,plr)
local alert = plr.PlayerGui.Menu.Alert
plr.plrStats.rpName.Value = filteredNick
end)
game.Players.PlayerRemoving:Connect(function(player)
end)
Any help will be appreciated!