Hey guys, I’m trying to make is so that if a player clicks an ‘exit’ gui the ‘play’ gui also disappears, normally I can do this but I’m not sure how to do it in the server script without messing up my current script… I’d be very grateful for any help… heres my server script and local scipt under starterGui.
(SERVER SCRIPT)
local start1 = workspace.start1
local start2 = workspace.start2
local isTouched1 = false
local isTouched2 = false
local exitGui = game.StarterGui.SwordFightPlay.ExitButton
local playGui = game.StarterGui.SwordFightPlay.PlayButton
playGui.Visible = false
local start1OriginalColor = start1.BrickColor
local start2OriginalColor = start2.BrickColor
local visibleDone = false
function BothPartsTouched()
if visibleDone then return end
visibleDone = true
for _,v in ipairs(game.Players:GetChildren()) do
v.PlayerGui.SwordFightPlay.PlayButton.Visible = true
end
end
start1.Touched:Connect(function(p)
if p.Parent and p.Parent:FindFirstChild("Humanoid") ~= nil then
start1.BrickColor = BrickColor.new("Teal")
isTouched1 = true
if isTouched2 then -- no need to check isTouched1 since we already set it to true
BothPartsTouched()
end
end
end)
start2.Touched:Connect(function(p)
if p.Parent and p.Parent:FindFirstChild("Humanoid") ~= nil then
start2.BrickColor = BrickColor.new("Teal")
isTouched2 = true
if isTouched2 then
end
end
end)
start1.TouchEnded:Connect(function(p)
if p.Parent and p.Parent:FindFirstChild("Humanoid") ~= nil then
start1.BrickColor = start1OriginalColor
isTouched1 = false
end
end)
start2.TouchEnded:Connect(function(p)
if p.Parent and p.Parent:FindFirstChild("Humanoid") ~= nil then
start2.BrickColor = start2OriginalColor
isTouched2 = false
end
end)
if exitGui.MouseButton1Click then
playGui.Visible = false
end
(LOCAL SCRIPT)
local start1 = game.Workspace.start1
local start2 = game.Workspace.start2
local close1 = game.Workspace.close1
local frame = script.Parent
local closeButton = frame.closeButton
frame.Visible = false
local function exitGui(otherPart)
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player then
player.PlayerGui.SwordFightPlay.ExitButton.Visible = true
wait(0.5)
player.Character.Humanoid.WalkSpeed = 0
end
end
local function closeGui()
local player = game.Players.LocalPlayer
player.PlayerGui.SwordFightPlay.ExitButton.Visible = false
player.Character.HumanoidRootPart.CFrame = CFrame.new(close1.Position.X,close1.Position.Y + 3,close1.Position.Z)
player.Character.Humanoid.WalkSpeed = 16
end
start1.Touched:Connect(exitGui)
closeButton.MouseButton1Click:Connect(closeGui)
local function exitGui2(otherPart)
local player = game.Players:FindFirstChild(otherPart.Parent.Name)
if player then
player.PlayerGui.SwordFightPlay.ExitButton.Visible = true
wait(0.5)
player.Character.Humanoid.WalkSpeed = 0
end
end
local function closeGui2()
local player = game.Players.LocalPlayer
if player then
player.PlayerGui.SwordFightPlay.ExitButton.Visible = false
player.Character.HumanoidRootPart.CFrame = CFrame.new(close1.Position.X,close1.Position.Y + 3,close1.Position.Z)
player.Character.Humanoid.WalkSpeed = 16
end
end
start2.Touched:Connect(exitGui2)
closeButton.MouseButton1Click:Connect(closeGui2)