So by the title, probably seems to be a pretty simple solution? Well, although it probably is, it isn’t what you think. So I have this GUI that changes the player’s team, changes a few text labels so on and so forth, the problem is, it doesn’t work. The script was written by another user, but it still doesn’t work, and the post is pretty much dead at this point. So I am reposting here.
Script:
local tweenService = game:GetService("TweenService")
local lighting = game:GetService("Lighting")
local _workspace = game:GetService("Workspace")
local players = game:GetService("Players")
local teams = game:GetService("Teams")
local player = players.LocalPlayer
local teamVal = script.Parent.Team
local team = "Class D"
local teams = {
[1] = "Class D",
[2] = "Foundation Personnel",
[3] = "Security Department",
[4] = "Medical Department",
[5] = "Scientific Department",
[6] = "Ethics Committee",
[7] = "Department of External Affairs",
[8] = "Mobile Task Force",
[9] = "Rapid Response Team",
[10] = "Internal Security Department",
[11] = "Intelligence Agency",
[12] = "Facility Executive",
[13] = "Chaos Insurgency",
[14] = "SCP",
[15] = "O5 Command"
}
teamVal:GetPropertyChangedSignal("Value"):Connect(function()
if not table.find(teams, teamVal.Value) then return end
if teamVal.Value == "Class D" or teamVal.Value == "O5 Command" then
script.Parent.Button1.Visible = false
end
if teamVal.Value == "Foundation Personnel" or teamVal.Value == "SCP" then
script.Parent.Button1.Visible = true
end
team = teams[teamVal.Value]
script.Parent["Team Lable"].Text = "Current Team Selected: "..team..""
end)
player.PlayerGui.MainMenu.GUIVis.Value = 1
script.Parent.Play.TextButton.MouseButton1Click:Connect(function()
player.Team = teams[team]
local tween = tweenService:Create(script.Parent.Parent.Black,
TweenInfo.new(
0.2,
Enum.EasingStyle.Sine,
Enum.EasingDirection.Out,
0,
true
), {BackgroundTransparency = 0}
):Play()
local a, e = pcall(function()
player.Character.Humanoid.MaxHealth = 0
player.Character.Humanoid.Health = 0
script.Parent.EffectHover:Play()
wait(0.2)
script.Parent.Visible = false
script.Parent.Parent.Main.Visible = true
script.Parent.Parent.Enabled = false
lighting.MenuBlur.Size = 0
_workspace.Camera.CameraType = Enum.CameraType.Custom
player.PlayerGui.MainMenu.GUIVis.Value = 0
end)
if not a then
warn(string.format("Something went wrong :C \n %s", e))
end
end)
GUI File if you’re interested: MainGUI.rbxm (15.3 KB)
You cannot change the player’s team from the client. You would need to set up a RemoteEvent and change the team via the server. BUT, you would need to secure this RemoteEvent from exploiters. Let me know if further explanation is needed.
I see, how would you recommend going about setting up the server script so that It knows A. when the arrows in the GUI are pressed and B. which teams there all are?
I dont think there is a script (section of the script) that checks what team is selected in this script, but you can use a remote event to pass in the arguments. and for the teams there are, you can make the same table in the server script
First of all, if there are any requirements for certain teams (such as ranks or gamepasses) you must declare them both in the client script and the server script. Everything that is currently set up in the client script can stay except for:
That line will be replaced with the RemoteEvent. Here is how we would go about doing so:
First, obviously, create a RemoteEvent and parent it to ReplicatedStorage. Name the RemoteEvent TeamEvent just so it is easy to recognize.
In the client script, you would replace the above line with:
That should be it. PLEASE NOTE: If you need requirements for certain teams, such as rank requirements or gamepasses, this MUST be revised, or else exploiters can easily bypass it. Let me know if that is something you need. Otherwise, this should work perfectly, assuming the rest of the code is fine.
Yeah it was mostly this, and securing the remote event, but this was still helpful nevertheless as I was unsure at first which line to replace. Sorry for being vague in my reply.
The only issue now is that the arrow GUI buttons I added don’t change which team is selected and the text label I have at the top doesn’t show what team is selected, I’d imagine this is probably another issue in the script however, no errors though.
If this is your only code regarding the GUI buttons, there is not any functions that detect your method of changing the team or at least I don’t think.
(by “this code” I’m referring to the code you sent at the very beginning)