I have been trying to figure this out alone for 4 hours straight, its a major flaw in my game and I have had no luck at all.
So pretty much you can go into a ui click a button that will fire a remote event to start a match and then after its over you want to fire it again and it does it twice, i have taken every precaution to even disconnect the events but still no luck.
Here is where the event is taking place… (local)
local connection
connection = ReplicatedStorage.Remotes.Tycoon_Function_Remotes.OfficialGameRemote.OnClientEvent:Connect(function(player)
if LocalPlayer.ValuesGame.Practice.Value == false then
if LocalPlayer.ValuesGame.Game.Value == false then
ClickUI:Play()
BlurTween()
MainFrame.Visible = false
task.wait(5)
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.FetchTeamData:FireServer(player)
--=========== CAMERAS
local connection2
connection2 = ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.FetchTeamData.OnClientEvent:Connect(function(Teamname)
local GameCameras = Workspace:WaitForChild("Tycoon").Tycoons:WaitForChild(Teamname).Essentials.GamedayCameras
Camera.CameraType = Enum.CameraType.Scriptable
local CamTween1 = TweenService:Create(Camera,TweenInfo.new(
3,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In),
{
CFrame = GameCameras.Camera1.CFrame
})
CamTween1:Play()
StadiumAmbience:Play()
CamTween1.Completed:Wait()
TutorialText.Text = ""
TutorialText.Visible = true
UnBlurTween()
task.wait(3)
PlayerGui.Player.Skip.Visible = true
PlayerGui.Player.Skip.MouseButton1Click:Connect(function(plr)
PlayerGui.Player.GameUI.Visible = true
PlayerGui.Player:WaitForChild("Skip").Visible = false
PlayerGui.Player.Skip.Value.Value = true
ClickUI:Play()
typewrite(TutorialText, "")
TutorialText.Text = ""
TutorialText.Visible = false
CameraNormal()
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.StartGame:FireServer(plr)
SoundService.Gameday:WaitForChild("Spotlights"):Stop()
end)
--// Game Commentary Start
SoundService.Gameday:WaitForChild("Spotlights"):Play()
task.wait(1)
typewrite(TutorialText, "IT IS TIME!!")
PlayerGui.Player.Skip.Visible = false
if PlayerGui.Player.Skip.Value.Value == true then
else
local CamTween2 = TweenService:Create(Camera,TweenInfo.new(
3,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In),
{
CFrame = GameCameras.Camera2.CFrame
})
CamTween2:Play()
task.wait(1)
typewrite(TutorialText, "Today the "..LocalPlayer.ValuesGame.TeamName.Value.." will be facing the ".. randomteam.." this will be a very good game!")
task.wait(1)
local CamTween3 = TweenService:Create(Camera,TweenInfo.new(
5,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In),
{
CFrame = GameCameras.Camera3.CFrame
})
CamTween3:Play()
typewrite(TutorialText, "We welcome you to the Week ".. LocalPlayer.ValuesGame.Team.Week.Value.. " matchup and we bring you now down to the coin toss.")
TutorialText.Visible = false
task.wait(1)
local CoinFlip = PlayerGui.Player.CoinFlip
CoinFlip.Visible = true
CoinFlip.Heads.MouseButton1Click:Connect(function(plr)
CoinFlip.Visible = false
ClickUI:Play()
local chance = math.random(1,100)
if chance > 50 then
CoinFlip.Flip.Value = true
CrowdCheer:Play()
TutorialText.Visible = true
typewrite(TutorialText, "It seems the ".. LocalPlayer.ValuesGame.TeamName.Value.." won the coin toss!")
elseif chance <= 50 then
CoinFlip.Flip.Value = true
CrowdAw:Play()
TutorialText.Visible = true
typewrite(TutorialText, "The ".. LocalPlayer.ValuesGame.TeamName.Value.." lost the coin toss. ")
end
end)
CoinFlip.Tails.MouseButton1Click:Connect(function(plr)
CoinFlip.Visible = false
ClickUI:Play()
local chance = math.random(1,100)
if chance > 50 then
CoinFlip.Flip.Value = true
CrowdCheer:Play()
TutorialText.Visible = true
typewrite(TutorialText, "It seems the ".. LocalPlayer.ValuesGame.TeamName.Value.." won the coin toss!")
elseif chance <= 50 then
CoinFlip.Flip.Value = true
CrowdAw:Play()
TutorialText.Visible = true
typewrite(TutorialText, "The ".. LocalPlayer.ValuesGame.TeamName.Value.." lost the coin toss. ")
end
end)
CoinFlip.Flip.Changed:Connect(function(plr)
task.wait(3)
local CamTween4 = TweenService:Create(Camera,TweenInfo.new(
3,
Enum.EasingStyle.Quad,
Enum.EasingDirection.In),
{
CFrame = GameCameras.Camera4.CFrame
})
CamTween4:Play()
typewrite(TutorialText, "The game is underway here at " .. LocalPlayer.ValuesGame.TeamName.Value.. " field!")
task.wait(3)
TutorialText.Visible = false
CameraNormal()
if PlayerGui.Player.Skip.Value.Value == true then
else
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.Gametime.StartGame:FireServer(plr)
PlayerGui.Player.GameUI.Visible = true
PlayerGui.Player.GameUI.TimeFrame.Quarter.Value += 1
end
end)
end
connection2:Disconnect()
end)
end
end
connection:Disconnect()
end)
Here is where the button is firing this event
local buttonClicked = false
actualstartgame = MainFrame.Gamestart.Yes.MouseButton1Click:Connect(function(player, ...)
if not buttonClicked then
buttonClicked = true
MainFrame.Gamestart.Visible = false
MainFrame.Visible = false
ReplicatedStorage.Remotes.Tycoon_Function_Remotes.OfficialGameRemote:FireServer(player)
end
end)
Here is where the event is going to the server (this fires back to the client taken place in the 1st code linked)
local connection
connection = ReplicatedStorage.Remotes.Tycoon_Function_Remotes.OfficialGameRemote.OnServerEvent:Connect(function(player)
local remoteEvent = ReplicatedStorage.Remotes.Tycoon_Function_Remotes.OfficialGameRemote
-- Optionally, you can fire the event back to the client
remoteEvent:FireClient(player)
connection:Disconnect()
end)
anybody knows whats going on, please help and thank you if you do I very very much appreciate it.