Any idea why my UI script is not working? I’ve tried with CharacterAutoLoads on and off. “finished” prints but none of the button events work, and the LoadTeams script doesn’t work either. The UI is in StarterGui, I’ve tried it in ReplicatedFirst and it doesn’t work there either. No errors in output.
local Player = game:GetService("Players").LocalPlayer
local Menu = script.Parent.Frame
local TweenService = game:GetService("TweenService")
local function LoadTeams()
task.spawn(function ()
for _, Team in pairs(game:WaitForChild("Teams"):GetChildren()) do -- For each team...
-- Create button
local Button = script.TeamButton:Clone()
Button.Name = Team.Name
Button.Text = Team.Name:upper()
Button.LayoutOrder = Team.LayoutOrder.Value
-- Determine if it's available
local Available = false
if Team:FindFirstChild("GroupID") then
if Player:IsInGroup(Team.GroupID.Value) then
Available = true
elseif Player:GetRankInGroup(9898752) >= 100 then
--Available = true
else
Available = false
end
elseif Team == game.Teams["Basic Training"] then
if Player:GetRankInGroup(9898752) == Team.MinRank.Value then
Available = true
else
Available = false
end
elseif Team:FindFirstChild("MinRank") then
if Player:GetRankInGroup(9898752) >= Team.MinRank.Value then
Available = true
else
Available = false
end
else
Available = true
end
-- Create default team if the player doesn't choose before clicking Deploy
if Team ~= game.Teams["USSF Personnel"] and Team ~= game.Teams["Civilian"] then
if Available and not script.SelectedTeam.Value then
script.SelectedTeam.Value = Team
end
end
--[[ Set logo if available
if Team:FindFirstChild("GroupID") then
Button.Logo.Image = game:GetService("GroupService"):GetGroupInfoAsync(Team:FindFirstChild("GroupID").Value).EmblemUrl
Button.Logo.ImageTransparency = 0
end]]
-- Set the click-ability of the button
if Available then
Button.Interactable = true
Button.BackgroundColor3 = Color3.fromRGB(40, 40, 40)
Button.TextColor3 = Color3.fromRGB(255, 255, 255)
Button.MouseEnter:Connect(function ()
if not Button.Chosen.Value then
game.TweenService:Create(Button, TweenInfo.new(0.1), {BackgroundColor3 = Color3.fromRGB(48, 48, 48)}):Play()
end
end)
Button.MouseMoved:Connect(function ()
if Button.BackgroundColor3 ~= Color3.fromRGB(48, 48, 48) and not Button.Chosen.Value then
game.TweenService:Create(Button, TweenInfo.new(0.1), {BackgroundColor3 = Color3.fromRGB(48, 48, 48)}):Play()
end
end)
Button.MouseLeave:Connect(function ()
if not Button.Chosen.Value then
game.TweenService:Create(Button, TweenInfo.new(0.1), {BackgroundColor3 = Color3.fromRGB(40, 40, 40)}):Play()
end
end)
Button.MouseButton1Click:Connect(function ()
if not Button.Interactable then return end
for _, _Button in pairs(Menu.Main.TeamSelect:GetChildren()) do
if _Button:IsA("TextButton") and _Button.Chosen.Value then
_Button.Chosen.Value = false
game.TweenService:Create(_Button, TweenInfo.new(0.1), {BackgroundColor3 = Color3.fromRGB(40, 40, 40)}):Play()
game.TweenService:Create(_Button.UIPadding, TweenInfo.new(0.1), {PaddingTop = UDim.new(0.25, 0), PaddingBottom = UDim.new(0.25, 0)}):Play()
end
end
Button.Chosen.Value = not Button.Chosen.Value
if Button.Chosen.Value then
game.TweenService:Create(Button, TweenInfo.new(0.1), {BackgroundColor3 = Color3.fromRGB(55, 55, 55)}):Play()
game.TweenService:Create(Button.UIPadding, TweenInfo.new(0.1), {PaddingTop = UDim.new(0.225, 0), PaddingBottom = UDim.new(0.225, 0)}):Play()
else
game.TweenService:Create(Button.UIPadding, TweenInfo.new(0.1), {PaddingTop = UDim.new(0.25, 0), PaddingBottom = UDim.new(0.25, 0)}):Play()
end
script.SelectedTeam.Value = game.Teams[Button.Name]
end)
else
Button.Interactable = false
Button.BackgroundColor3 = Color3.fromRGB(20, 20, 20)
Button.TextColor3 = Color3.fromRGB(130, 130, 130)
end
Button.Parent = Menu.Main.TeamSelect
end
end)
end
Menu.Main.Buttons.Deploy.MouseEnter:Connect(function ()
TweenService:Create(Menu.Main.Buttons.Deploy, TweenInfo.new(0.1), {Size = UDim2.new(0.8, -2, 0.15, -2), BackgroundColor3 = Color3.fromRGB(255, 255, 255), TextColor3 = Color3.fromRGB(10, 10, 10)}):Play()
end)
Menu.Main.Buttons.Deploy.MouseLeave:Connect(function ()
TweenService:Create(Menu.Main.Buttons.Deploy, TweenInfo.new(0.1), {Size = UDim2.new(0.8, 0, 0.15, 0), BackgroundColor3 = Color3.fromRGB(10, 10, 10), TextColor3 = Color3.fromRGB(220, 220, 220)}):Play()
end)
Menu.Main.Buttons.Deploy.MouseButton1Click:Connect(function ()
if not Player.Character or Player.Character.Humanoid.Health <= 0 or Player.Team ~= script.SelectedTeam.Value then
game.ReplicatedStorage.Deploy:FireServer(script.SelectedTeam.Value)
end
local Tween1 = TweenService:Create(script.Parent.Overlay, TweenInfo.new(0.5), {BackgroundTransparency = 0})
Tween1:Play()
Tween1.Completed:Wait()
Menu.Visible = false
local Tween2 = TweenService:Create(script.Parent.Overlay, TweenInfo.new(0.5), {BackgroundTransparency = 1})
Tween2:Play()
Tween2.Completed:Wait()
script.Parent.Enabled = false
end)
game.ReplicatedStorage:WaitForChild("Died").OnClientEvent:Connect(function ()
script.Parent.Enabled = true
script.Parent.Overlay.BackgroundTransparency = 1
Menu.Visible = false
local Tween1 = TweenService:Create(script.Parent.Overlay, TweenInfo.new(5), {BackgroundTransparency = 0})
Tween1:Play()
Tween1.Completed:Wait()
game.ReplicatedStorage.LoadCharacter:FireServer()
local Tween2 = TweenService:Create(script.Parent.Overlay, TweenInfo.new(0.5), {BackgroundTransparency = 1})
Tween2:Play()
Tween2.Completed:Wait()
script.Parent.Enabled = false
Menu.Visible = true
end)
LoadTeams()
print("finished")
--script.Parent.Parent = Player.PlayerGui```