For some reason the GUI buttons don’t always fire when clicked or there is a serious delay.
(Example below) Does someone know how I can fix this?
Local Script:
task.wait(1)
local ReplicatedStorage = game:GetService("ReplicatedStorage")
local TweenService = game:GetService("TweenService")
local Remote = ReplicatedStorage.ExploitProtectionRemoteEvents.ChangePlayerTeam
local TeamsFrame = script.Parent.Folder.Teams
local PlayFrame = script.Parent.Folder.Play
local Player = game.Players.LocalPlayer
local PlatButton = PlayFrame.PlayButton
local TeamButton = TeamsFrame.TeamsButton
local Camera = workspace.Camera
local Goal = {BackgroundTransparency = 1}
local Goal2 = {TextTransparency = 1}
local GuiObjects = script.Parent.Folder:GetDescendants()
local FocusPart = workspace:WaitForChild("FocusPartDoNotDelete")
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = FocusPart.CFrame
script.Parent.Enabled = true
function OnTeamButtonPressed()
for i, GuiObject in pairs(GuiObjects) do
if GuiObject:IsA("GuiObject") then
if GuiObject:IsA("TextButton") then
TweenService:Create(GuiObject, TweenInfo.new(0.4), Goal2):Play()
else
TweenService:Create(GuiObject, TweenInfo.new(0.4), Goal):Play()
end
end
end
for i, GuiObject in pairs(script.Parent.TeamChoose:GetDescendants()) do
if GuiObject:IsA("GuiObject") then
if GuiObject:IsA("TextLabel") then
TweenService:Create(GuiObject, TweenInfo.new(0.4), {TextTransparency = 0}):Play()
else
TweenService:Create(GuiObject, TweenInfo.new(0.4), {BackgroundTransparency = 0}):Play()
end
end
end
end
function GuiReset()
script.Parent.TeamChoose.Police.BackgroundTransparency = 1
script.Parent.TeamChoose.Civ.BackgroundTransparency = 1
TeamsFrame.BackgroundTransparency = 0
TeamsFrame.TeamsButton.TextTransparency = 0
PlayFrame.BackgroundTransparency = 0
PlayFrame.PlayButton.TextTransparency = 0
end
TeamsFrame.TeamsButton.MouseButton1Click:Connect(OnTeamButtonPressed)
script.Parent.TeamChoose.Police.MouseButton1Click:Connect(function()
print("Fired")
Remote:FireServer(BrickColor.new("Really blue"))
GuiReset()
end)
script.Parent.TeamChoose.Civ.MouseButton1Click:Connect(function()
print("Fired2")
Remote:FireServer(BrickColor.new("Neon orange"))
GuiReset()
end)
Example:
(There’s quite some delay)