So this is the whole script : ~~~~~~~~~~~~~~~~~
~~~~~~~~~~~~~~~~~
local Player = game.Players.LocalPlayer
for i,v in pairs(script.Parent.MainFrame.ScrollingFrame:GetChildren()) do if v:IsA("TextButton") then v.MouseButton1Click:Connect(function() if v:FindFirstChild("Group Settings") then if Player:GetRankInGroup(v["Group Settings"].GroupId.Value) < v["Group Settings"].MinRank.Value then return end end
if game:FindFirstChild("Teams") == nil then ErrorMsg("ERROR: You haven't inserted any teams in your game.") elseif game.Teams:FindFirstChild(v.Text) == nil then ErrorMsg("ERROR: The text of the button must be the same as the team name.") else game.ReplicatedStorage.TeamChanger:FireServer(v.Text) end end) end
end
function ErrorMsg(Msg) local M = Instance.new("Message") M.Text = Msg M.Parent = game.Workspace game.Debris:AddItem(M, 5) end
So this is the script far.There is one more script for this.
local TC = Instance.new("RemoteEvent") TC.Name = "TeamChanger" TC.Parent = game.ReplicatedStorage
TC.OnServerEvent:Connect(function(Player, TeamName) Player.Team = game.Teams[TeamName] Player:LoadCharacter() end)
Now some of the script dont get in the Lua Block but i dont know what to do with it.
I have just modified these scripts and it seems to work fine.
In a NORMAL SCRIPT in ServerScriptService put in this code:
local TC = Instance.new("RemoteEvent") TC.Name = "TeamChanger" TC.Parent = game:GetService('ReplicatedStorage') --In case it gets renamed or something TC.OnServerEvent:Connect(function(Player, TeamName) Player.Team = game.Teams[TeamName] Player:LoadCharacter() end)
In a LOCAL SCRIPT in the Parent of MainFrame put this code in:
local Player = game.Players.LocalPlayer for i,v in pairs(script.Parent.MainFrame.ScrollingFrame:GetChildren()) do if v:IsA("TextButton") then v.MouseButton1Click:Connect(function() if v:FindFirstChild("Group Settings") then if Player:GetRankInGroup(v["Group Settings"].GroupId.Value) < v["Group Settings"].MinRank.Value then return end end if game:FindFirstChild("Teams") == nil then ErrorMsg("ERROR: You haven't inserted any teams in your game.") elseif game.Teams:FindFirstChild(v.Text) == nil then ErrorMsg("ERROR: The text of the button must be the same as the team name.") else game.ReplicatedStorage:WaitForChild('TeamChanger'):FireServer(v.Text) --Waits for TeamChanger to be created. end end) end end function ErrorMsg(Msg) local M = Instance.new("Message") M.Text = Msg M.Parent = game.Workspace game.Debris:AddItem(M, 5) end
I explained what I changed in the scripts and make sure you're using the correct class types and in the correct places.
Let me know if you encounter any other issues.