Okay, so let me explain. I already have a team changer,
Here is the code:
function Click(mouse)
if script.Parent.Parent.Parent.Parent.Parent:IsInGroup(10616859) then
script.Parent.Parent.Parent.Parent.Parent.TeamColor = BrickColor.new("Storm blue")
end
end
script.Parent.MouseButton1Click:connect(Click)
I am very new to scripting, I do know some basics and continue to learn. Just I’d like help from now!
Since I’m new please be more helpful then most of the time, thanks!
If you mean like when player joins he will be like “Blue Team” then this is a script for it…
game.Players.PlayerAdded:connect(function(newPlayer)
local rank = newPlayer:GetRankInGroup(GroupID)
local teamName = ""
if rank == 0 then
teamName = "Visitor"
end
newPlayer.TeamColor = game.Teams[teamName].TeamColor
end)
Basically, They would click on Team GUI, it opens all the available teams and I want to make it so one certain team cannot be joined unless their at a Certain Group Rank. I only made it so it’s only a certain group.
The best way to do this would be to use a LocalScript, and reference the Player using game.Players.LocalPlayer
You can probably change the Team’s Color by sending a RemoteEvent, from the client to the server to receive it’s changes
--LocalScript
local Player = game.Players.LocalPlayer
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local function Click()
Event:FireServer()
end
script.Parent.MouseButton1Click:Connect(Click)
--Here, we insert a script inside ServerScriptService to receive the event fired from the client
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
Event.OnServerEvent:Connect(function(Player)
if Player:IsInGroup(10616859) then
Player.TeamColor = BrickColor.new("Storm blue")
end
end)
From what I’m understanding, this seems like when the player is added? I’m looking for when the button is clicked it will team them that, I may be wrong though?
Well, i’m looking so it is able to be a Group Rank, that seems to be a Group Only team. So I want it to basically be, you click on the GUI if your for example 2+ rank(id) it will let you on the team, otherelse it wont.
I see, use the Player:GetRankInGroup function then
Try this inside your server side:
--Here, we insert a script inside ServerScriptService to receive the event fired from the client
local Event = game.ReplicatedStorage:WaitForChild("RemoteEvent")
Event.OnServerEvent:Connect(function(Player)
if Player:IsInGroup(10616859) and Player:GetRankInGroup(10616859) >= 2 then
Player.TeamColor = BrickColor.new("Storm blue")
end
end)
Yep, this will also check if the Player is in that specific group to prevent any sort of erroring as well, otherwise it’d return back as false and won’t set the TeamColor