My GUI has a problem when I press Test Game ServerFrame is displayed even though. I set it to not visible and when you press Back, the GUI will find it. I tried many times same result. Can someone check it for me?
It will appear at the start of the game.
when you press “Back”.
//นี่คือสคริปต์ที่เขียนรวมใน GUI อันเดียว
--[DISABLE RESETTING CHARACTER ON START]--
game.StarterGui:SetCore("ResetButtonCallback", false)
--[DISABLE RESETTING CHARACTER ON START]--
game.StarterGui:SetCore("ResetButtonCallback", false)
--[Variables]--
local tweenService = game:GetService("TweenService")
local marketplaceService = game:GetService("MarketplaceService")
local mouse = game.Players.LocalPlayer:GetMouse()
local camera = workspace.CurrentCamera
local gui = script.Parent
local serverBtn = gui.ButtonsContainer:WaitForChild("SeverButtom")
local settingsBtn = gui.ButtonsContainer:WaitForChild("SettingsButton")
local shopBtn = gui.ButtonsContainer:WaitForChild("ShopButton")
local Training = gui:WaitForChild("ButtonsContainer"):WaitForChild("Training zone")
local Zombie = gui:WaitForChild("ButtonsContainer"):WaitForChild("Zombie Mode")
local settingsFrame = gui:WaitForChild("SettingsFrame")
local shopFrame = gui:WaitForChild("ShopFrame")
local ServerFrame = gui:WaitForChild("ServerFrame")
local s = game:service("TeleportService")
--[Menu Scene]--
local cameraPart = workspace:WaitForChild("MenuScene").CameraPart
local characterPart = workspace.MenuScene.CharacterPart
--Camera
camera.CameraType = Enum.CameraType.Scriptable
camera.CFrame = cameraPart.CFrame
local playClicked = false
game:GetService("RunService").RenderStepped:Connect(function()
if not playClicked then
camera.CameraType = Enum.CameraType.Scriptable
local centreOfScreen = Vector2.new(camera.ViewportSize.X / 2, camera.ViewportSize.Y / 2)
local mouseDistanceFromCentre = Vector3.new((-mouse.X - centreOfScreen.X)/5000, (mouse.Y - centreOfScreen.Y)/5000, 0)
camera.CFrame = cameraPart.CFrame * CFrame.new(cameraPart.CFrame.LookVector + mouseDistanceFromCentre)
end
end)
--Character
local character = game.Players.LocalPlayer.Character
character:WaitForChild("Humanoid").WalkSpeed = 0
character.Humanoid.JumpHeight = 0
character.HumanoidRootPart.CFrame = characterPart.CFrame
--[Hover Button Effect]--
for i, descendant in pairs(gui:GetDescendants()) do
if descendant:IsA("TextButton") or descendant:IsA("ImageButton") then
local originalSize = descendant.Size
local hoverSize = UDim2.new(originalSize.X.Scale * 1.01, 0, originalSize.Y.Scale * 1.01, 0)
descendant.MouseEnter:Connect(function()
script.HoverSound:Play()
descendant:TweenSize(hoverSize, "InOut", "Quint", 0.2, true)
end)
descendant.MouseLeave:Connect(function()
descendant:TweenSize(originalSize, "InOut", "Quint", 0.2, true)
end)
end
end
--[Menu Buttons]--
settingsFrame.Position = UDim2.new(-0.5, 0, 0.5, 0)
shopFrame.Position = UDim2.new(-0.5, 0, 0.5, 0)
ServerFrame.Visible = true
settingsFrame.Visible = true
shopFrame.Visible = true
local serverOpen = false
local settingsOpen = false
local shopOpen = false
--Sever Button
serverBtn.MouseButton1Click:Connect(function()
if not serverOpen then
serverOpen = true
if shopOpen then
shopOpen = false
shopFrame:TweenPosition(UDim2.new(1.5, 0, 0.5, 0), "Out", "Quint", 0.3, true)
settingsFrame:TweenPosition(UDim2.new(1.5, 0, 0.5, 0), "Out", "Quint", 0.3, true)
end
script.ClickSound:Play()
ServerFrame.Position = UDim2.new(-0.5, 0, 0.5, 0)
ServerFrame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), "Out", "Quint", 0.3, true)
end
end)
--Settings Button
settingsBtn.MouseButton1Click:Connect(function()
if not settingsOpen then
settingsOpen = true
if shopOpen then
shopOpen = false
shopFrame:TweenPosition(UDim2.new(1.5, 0, 0.5, 0), "Out", "Quint", 0.3, true)
ServerFrame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), "Out", "Quint", 0.3, true)
end
script.ClickSound:Play()
settingsFrame.Position = UDim2.new(-0.5, 0, 0.5, 0)
settingsFrame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), "Out", "Quint", 0.3, true)
end
end)
--Shop Button
shopBtn.MouseButton1Click:Connect(function()
if not shopOpen then
shopOpen = true
if settingsOpen then
settingsOpen = false
settingsFrame:TweenPosition(UDim2.new(1.5, 0, 0.5, 0), "Out", "Quint", 0.3, true)
ServerFrame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), "Out", "Quint", 0.3, true)
end
script.ClickSound:Play()
shopFrame.Position = UDim2.new(-0.5, 0, 0.5, 0)
shopFrame:TweenPosition(UDim2.new(0.5, 0, 0.5, 0), "Out", "Quint", 0.3, true)
end
end)
--Training Zone
Training.MouseButton1Click:Connect(function()
if not playClicked then
playClicked = true
local s = game:service("TeleportService")
wait()
s:Teleport(00000000) --place number
script.ClickSound:Play()
settingsFrame:TweenPosition(UDim2.new(settingsFrame.Position.X.Scale, 0, 1.5, 0), "In", "Back", 0.8, true)
shopFrame:TweenPosition(UDim2.new(shopFrame.Position.X.Scale, 0, 1.5, 0), "In", "Back", 0.8, true)
wait(0.2)
serverBtn:TweenPosition(UDim2.new(serverBtn.Position.X.Scale, 0, 1.5, 0), "In", "Back", 0.5, true)
wait(0.15)
settingsBtn:TweenPosition(UDim2.new(settingsBtn.Position.X.Scale, 0, 1.5, 0), "In", "Back", 0.5, true)
shopBtn:TweenPosition(UDim2.new(shopBtn.Position.X.Scale, 0, 1.5, 0), "In", "Back", 0.5, true)
Zombie:TweenPosition(UDim2.new(serverBtn.Position.X.Scale, 0, 1.5, 0), "In", "Back", 0.5, true)
wait(0.15)
end
end)
--Zombie Mode
Zombie.MouseButton1Click:Connect(function()
if not playClicked then
playClicked = true
local s = game:service("TeleportService")
wait()
s:Teleport(00000000) --place number
script.ClickSound:Play()
settingsFrame:TweenPosition(UDim2.new(settingsFrame.Position.X.Scale, 0, 1.5, 0), "In", "Back", 0.8, true)
shopFrame:TweenPosition(UDim2.new(shopFrame.Position.X.Scale, 0, 1.5, 0), "In", "Back", 0.8, true)
wait(0.2)
serverBtn:TweenPosition(UDim2.new(serverBtn.Position.X.Scale, 0, 1.5, 0), "In", "Back", 0.5, true)
wait(0.15)
settingsBtn:TweenPosition(UDim2.new(settingsBtn.Position.X.Scale, 0, 1.5, 0), "In", "Back", 0.5, true)
shopBtn:TweenPosition(UDim2.new(shopBtn.Position.X.Scale, 0, 1.5, 0), "In", "Back", 0.5, true)
Training:TweenPosition(UDim2.new(serverBtn.Position.X.Scale, 0, 1.5, 0), "In", "Back", 0.5, true)
wait(0.15)
end
end)
--Back Buttons
settingsFrame.BackButton.MouseButton1Click:Connect(function()
settingsOpen = false
script.ClickSound:Play()
settingsFrame:TweenPosition(UDim2.new(-0.5, 0, 0.5, 0), "Out", "Quint", 0.3, true)
end)
shopFrame.BackButton.MouseButton1Click:Connect(function()
shopOpen = false
script.ClickSound:Play()
shopFrame:TweenPosition(UDim2.new(-0.5, 0, 0.5, 0), "Out", "Quint", 0.3, true)
end)
ServerFrame.BackButton.MouseButton1Click:Connect(function()
serverOpen = false
script.ClickSound:Play()
ServerFrame:TweenPosition(UDim2.new(-0.5, 0, 0.5, 0), "Out", "Quint", 0.3, true)
end)
--[SETTINGS]--
local scroller = settingsFrame.SettingsScroller
local sliderOff = UDim2.new(0.189, 0, 0.493, 0)
local sliderOn = UDim2.new(0.806, 0, 0.493, 0)
local sliderOffColor = Color3.fromRGB(114, 115, 118)
local sliderOnColor = Color3.fromRGB(255, 255, 255)
--FOV Setting
scroller.FOVSetting.TextBox.FocusLost:Connect(function()
workspace.CurrentCamera.FieldOfView = tonumber(scroller.FOVSetting.TextBox.Text)
end)
--Low Graphics Setting
local lowGraphics = false
local tweenInfoSlider = TweenInfo.new(0.2, Enum.EasingStyle.Quint, Enum.EasingDirection.InOut)
scroller.LowGraphicsSetting.Slider.SliderCircle.Position = lowGraphics and sliderOn or sliderOff
scroller.LowGraphicsSetting.Slider.SliderCircle.BackgroundColor3 = lowGraphics and sliderOnColor or sliderOffColor
scroller.LowGraphicsSetting.Slider.MouseButton1Click:Connect(function()
lowGraphics = not lowGraphics
script.ClickSound:Play()
if lowGraphics then
scroller.LowGraphicsSetting.Slider.SliderCircle:TweenPosition(sliderOn, "InOut", "Quint", 0.2, true)
local colorTween = tweenService:Create(scroller.LowGraphicsSetting.Slider.SliderCircle, tweenInfoSlider, {BackgroundColor3 = sliderOnColor})
colorTween:Play()
else
scroller.LowGraphicsSetting.Slider.SliderCircle:TweenPosition(sliderOff, "InOut", "Quint", 0.2, true)
local colorTween = tweenService:Create(scroller.LowGraphicsSetting.Slider.SliderCircle, tweenInfoSlider, {BackgroundColor3 = sliderOffColor})
colorTween:Play()
end
for i, child in pairs(game.Lighting:GetChildren()) do
if child:IsA("BloomEffect") or child:IsA("DepthOfFieldEffect") or child:IsA("SunRaysEffect") or child:IsA("BlurEffect") or child:IsA("ColorCorrectionEffect") then
child.Enabled = not lowGraphics
end
end
game.Lighting.GlobalShadows = not lowGraphics
end)
--Textures Setting
local textures = true
scroller.TexturesSetting.Slider.SliderCircle.Position = textures and sliderOn or sliderOff
scroller.TexturesSetting.Slider.SliderCircle.BackgroundColor3 = textures and sliderOnColor or sliderOffColor
local texturesList = {}
scroller.TexturesSetting.Slider.MouseButton1Click:Connect(function()
textures = not textures
script.ClickSound:Play()
if textures then
scroller.TexturesSetting.Slider.SliderCircle:TweenPosition(sliderOn, "InOut", "Quint", 0.2, true)
local colorTween = tweenService:Create(scroller.TexturesSetting.Slider.SliderCircle, tweenInfoSlider, {BackgroundColor3 = sliderOnColor})
colorTween:Play()
else
scroller.TexturesSetting.Slider.SliderCircle:TweenPosition(sliderOff, "InOut", "Quint", 0.2, true)
local colorTween = tweenService:Create(scroller.TexturesSetting.Slider.SliderCircle, tweenInfoSlider, {BackgroundColor3 = sliderOffColor})
colorTween:Play()
end
for i, descendant in pairs(workspace:GetDescendants()) do
if descendant:IsA("Texture") then
local originalTransparency = descendant.Transparency
if not texturesList[descendant] then
texturesList[descendant] = originalTransparency
end
descendant.Transparency = textures and texturesList[descendant] or 1
end
end
end)
--Day Cycle Setting
local noDayCycle = false
scroller.DayCycleSetting.Slider.SliderCircle.Position = noDayCycle and sliderOn or sliderOff
scroller.DayCycleSetting.Slider.SliderCircle.BackgroundColor3 = noDayCycle and sliderOnColor or sliderOffColor
local currentTime = game.Lighting.ClockTime
scroller.DayCycleSetting.Slider.MouseButton1Click:Connect(function()
noDayCycle = not noDayCycle
script.ClickSound:Play()
if noDayCycle then
scroller.DayCycleSetting.Slider.SliderCircle:TweenPosition(sliderOn, "InOut", "Quint", 0.2, true)
local colorTween = tweenService:Create(scroller.DayCycleSetting.Slider.SliderCircle, tweenInfoSlider, {BackgroundColor3 = sliderOnColor})
colorTween:Play()
else
scroller.DayCycleSetting.Slider.SliderCircle:TweenPosition(sliderOff, "InOut", "Quint", 0.2, true)
local colorTween = tweenService:Create(scroller.DayCycleSetting.Slider.SliderCircle, tweenInfoSlider, {BackgroundColor3 = sliderOffColor})
colorTween:Play()
end
currentTime = game.Lighting.ClockTime
end)
spawn(function()
while wait() do
if noDayCycle then
game.Lighting.ClockTime = currentTime
else
game.Lighting.ClockTime += 0.001
end
end
end)
--Chat Setting
local noChat = false
scroller.ChatSetting.Slider.SliderCircle.Position = noChat and sliderOn or sliderOff
scroller.ChatSetting.Slider.SliderCircle.BackgroundColor3 = noChat and sliderOnColor or sliderOffColor
scroller.ChatSetting.Slider.MouseButton1Click:Connect(function()
noChat = not noChat
script.ClickSound:Play()
if noChat then
scroller.ChatSetting.Slider.SliderCircle:TweenPosition(sliderOn, "InOut", "Quint", 0.2, true)
local colorTween = tweenService:Create(scroller.ChatSetting.Slider.SliderCircle, tweenInfoSlider, {BackgroundColor3 = sliderOnColor})
colorTween:Play()
else
scroller.ChatSetting.Slider.SliderCircle:TweenPosition(sliderOff, "InOut", "Quint", 0.2, true)
local colorTween = tweenService:Create(scroller.ChatSetting.Slider.SliderCircle, tweenInfoSlider, {BackgroundColor3 = sliderOffColor})
colorTween:Play()
end
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Chat, not noChat)
end)
--Sound FX Setting
local soundFX = true
scroller.SoundFXSetting.Slider.SliderCircle.Position = soundFX and sliderOn or sliderOff
scroller.SoundFXSetting.Slider.SliderCircle.BackgroundColor3 = soundFX and sliderOnColor or sliderOffColor
local soundsList = {}
scroller.SoundFXSetting.Slider.MouseButton1Click:Connect(function()
soundFX = not soundFX
script.ClickSound:Play()
if soundFX then
scroller.SoundFXSetting.Slider.SliderCircle:TweenPosition(sliderOn, "InOut", "Quint", 0.2, true)
local colorTween = tweenService:Create(scroller.SoundFXSetting.Slider.SliderCircle, tweenInfoSlider, {BackgroundColor3 = sliderOnColor})
colorTween:Play()
else
scroller.SoundFXSetting.Slider.SliderCircle:TweenPosition(sliderOff, "InOut", "Quint", 0.2, true)
local colorTween = tweenService:Create(scroller.SoundFXSetting.Slider.SliderCircle, tweenInfoSlider, {BackgroundColor3 = sliderOffColor})
colorTween:Play()
end
for i, sound in pairs(script:GetChildren()) do
if sound:IsA("Sound") then
if not soundsList[sound] then
soundsList[sound] = sound.Volume
end
sound.Volume = soundFX and soundsList[sound] or 0
end
end
end)
--[SHOP]--
local gamepasses = {68236409, 68236590, 68236960, 68237410, 68237643}
for i, gamepass in pairs(gamepasses) do
local productInfo = marketplaceService:GetProductInfo(gamepass, Enum.InfoType.GamePass)
local newFrame = script.GamepassFrame:Clone()
newFrame.GamepassName.Text = productInfo.Name
newFrame.GamepassDescription.Text = productInfo.Description
newFrame.GamepassPrice.Text = productInfo.PriceInRobux .. "R$"
newFrame.GamepassIcon.Image = "rbxassetid://" .. productInfo.IconImageAssetId
newFrame.BuyButton.MouseButton1Click:Connect(function()
script.ClickSound:Play()
marketplaceService:PromptGamePassPurchase(game.Players.LocalPlayer, gamepass)
end)
newFrame.Parent = shopFrame.GamepassScroller
end
I apologize for the 400 line script.