So I have this script that’s a part of a GUI that changes the player’s team, but it has a few problems. The big one is as you can see from taking one look at it, it’s highly inefficient. I tried doing it with a table before but it broke, even more, this works for now. In addition, the script does not even work, and I have no idea why since there aren’t any errors in the output. So I was wondering A. how to make it more efficient and less complicated, and B. How to make it work. The part that does not work is the detection of the click.
Script:
local team = "Class D"
local teamVal = script.Parent.Team
local morph = "test"
while true do
wait(0.001)
if teamVal.Value == 1 then
team = "Class D"
script.Parent.Button2.Visible = false
end
if teamVal.Value == 2 then
team = "Foundation Personnel"
script.Parent.Button2.Visible = true
end
if teamVal.Value == 3 then
team = "Security Department"
end
if teamVal.Value == 4 then
team = "Medical Department"
end
if teamVal.Value == 5 then
team = "Scientific Department"
end
if teamVal.Value == 6 then
team = "Ethics Committee"
end
if teamVal.Value == 7 then
team = "Department of External Affairs"
end
if teamVal.Value == 8 then
team = "Mobile Task Force"
end
if teamVal.Value == 9 then
team = "Rapid Response Team"
end
if teamVal.Value == 10 then
team = "Internal Security Department"
end
if teamVal.Value == 11 then
team = "Intelligence Agency"
end
if teamVal.Value == 12 then
team = "Facility Executive"
end
if teamVal.Value == 13 then
team = "Chaos Insurgency"
end
if teamVal.Value == 14 then
team = "SCP"
script.Parent.Button1.Visible = true
end
if teamVal.Value == 15 then
team = "O5 Command"
script.Parent.Button1.Visible = false
end
script.Parent["Team Lable"].Text = "Current Team Selected: "..team..""
end
local Players = game:GetService("Players")
-----
game.StarterGui.MainMenu.GUIVis.Value = 1
local tweenservice = game:GetService("TweenService")
local fadebackground = script.Parent.Parent.Black
local tweenInfo = TweenInfo.new(
0.2,--time in seconds
Enum.EasingStyle.Sine, --smooth
Enum.EasingDirection.Out, --dont change
0, -- dont change
true, --reverse
0
)
local tween = tweenservice:Create(fadebackground, tweenInfo, {BackgroundTransparency = 0})
local player = game.Players.LocalPlayer
function leftClick()
player.Team = team
tween:Play()
game:GetService("Players").LocalPlayer.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
game.Lighting.MenuBlur.Size = 0
game.Workspace.Camera.CameraType = Enum.CameraType.Custom
game.StarterGui.MainMenu.GUIVis.Value = 0
end
script.Parent.Play.TextButton.MouseButton1Click:Connect(leftClick)
local team = "Class D"
local teamVal = script.Parent.Team
local morph = "test"
while true do
wait(0.001)
if teamVal.Value == 1 then
team = "Class D"
script.Parent.Button2.Visible = false
end
if teamVal.Value == 2 then
team = "Foundation Personnel"
script.Parent.Button2.Visible = true
end
if teamVal.Value == 3 then
team = "Security Department"
end
if teamVal.Value == 4 then
team = "Medical Department"
end
if teamVal.Value == 5 then
team = "Scientific Department"
end
if teamVal.Value == 6 then
team = "Ethics Committee"
end
if teamVal.Value == 7 then
team = "Department of External Affairs"
end
if teamVal.Value == 8 then
team = "Mobile Task Force"
end
if teamVal.Value == 9 then
team = "Rapid Response Team"
end
if teamVal.Value == 10 then
team = "Internal Security Department"
end
if teamVal.Value == 11 then
team = "Intelligence Agency"
end
if teamVal.Value == 12 then
team = "Facility Executive"
end
if teamVal.Value == 13 then
team = "Chaos Insurgency"
end
if teamVal.Value == 14 then
team = "SCP"
script.Parent.Button1.Visible = true
end
if teamVal.Value == 15 then
team = "O5 Command"
script.Parent.Button1.Visible = false
end
script.Parent["Team Lable"].Text = "Current Team Selected: "..team..""
end --[[---]]
game.StarterGui.MainMenu.GUIVis.Value = 1
local tweenservice = game:GetService("TweenService")
local fadebackground = script.Parent.Parent.Black
local tweenInfo = TweenInfo.new( 0.2, --[[time in seconds]] Enum.EasingStyle.Sine, --[[smooth]] Enum.EasingDirection.Out, --[[dont change]] 0, --[[ dont change]] true, --[[reverse]] 0 )
function leftClick()
end
The only problem is now I no longer have the tween variable to play the tween when clicked. Also out of curiosity, I was wondering if you knew if there was any way to condense the first part from a ton of if statements to a table, I’m not a very advanced scripter so I have no idea if it is or not, just wondering.
local c = "Class D"
local b = script.Parent.Team
local a = "test"
while true do
wait(0.001)
if b.Value == 1 then
c = "Class D"
script.Parent.Button2.Visible = false
end
if b.Value == 2 then
c = "Foundation Personnel"
script.Parent.Button2.Visible = true
end
if b.Value == 3 then
c = "Security Department"
end
if b.Value == 4 then
c = "Medical Department"
end
if b.Value == 5 then
c = "Scientific Department"
end
if b.Value == 6 then
c = "Ethics Committee"
end
if b.Value == 7 then
c = "Department of External Affairs"
end
if b.Value == 8 then
c = "Mobile Task Force"
end
if b.Value == 9 then
c = "Rapid Response Team"
end
if b.Value == 10 then
c = "Internal Security Department"
end
if b.Value == 11 then
c = "Intelligence Agency"
end
if b.Value == 12 then
c = "Facility Executive"
end
if b.Value == 13 then
c = "Chaos Insurgency"
end
if b.Value == 14 then
c = "SCP"
script.Parent.Button1.Visible = true
end
if b.Value == 15 then
c = "O5 Command"
script.Parent.Button1.Visible = false
end
script.Parent["Team Lable"].Text = "Current Team Selected: "..c..""
end --[[---]]
game.StarterGui.MainMenu.GUIVis.Value = 1
local a = game:GetService("TweenService")
local a = script.Parent.Parent.Black
local a = TweenInfo.new( 0.2, --[[time in seconds]] Enum.EasingStyle.Sine, --[[smooth]] Enum.EasingDirection.Out, --[[dont change]] 0, --[[ dont change]] true, --[[reverse]] 0 )
function leftClick()
end
Although there is not an error for it, the part of my script that changes a GUI label based on what team has been selected doesn’t work anymore. Also the part of the system that is used to change which team you are going to select also no longer works. Although the Select team button does work along with tweens, the rest of the team select system does not.
Maybe this will help, the top part is supposed to say whatever team is selected, for example, “Current Team Selected: Mobile Task Force”. Also, the arrows at the bottom were supposed to change whichever team was selected in addition to hiding for example the righthand arrow if you were at the last team and lefthand if you were at the first. Kind of make sense?
don’t use getpropertychanged signal, just use .Changed, in my experience of using both GetPropertyChangedSignal barely ever works. Changed passes the changed value as an argument, if you really need it. And what kind of value is the teamVal? You should try to make it an IntValue, NumberValues can be decimals from what I remember.