Skip Cutscene Button Not Functioning

I am trying to make a skip cutscene/skip intro button, that takes the amount of players in the server, and when the player skips, the serverscript fires to all clients that a player has voted to skip, and in the client script, if the amount of people that voted equals to the amount of people in the server, it will print ("Skipped cutscene.").

However, this is not working for some reason. I tried another way to do this by using several remote events instead of one, but that made it more chaotic.

Server Script:

wait(8)

game.Players.PlayerAdded:Connect(function(Player)
	Player.PlayerGui.LoadingGui.BackroundFrame.SkipButton.MouseButton1Click:Connect(function()
		print("clicked")
		Player.PlayerGui.LoadingGui.BackroundFrame.SkipButton.Active = false
		game.ReplicatedStorage.FireVoteToClient:FireAllClients()
	end)
end)

Client Script:

local Players = game:GetService("Players")
local AmountOfPlayers = #Players:GetPlayers()
local VotedSoFar = script:WaitForChild("NumberOfVotes")

Players.PlayerAdded:Connect(function(Player)
	AmountOfPlayers = AmountOfPlayers + 1
	script.Parent.Text = ("Skip " .. "(" ..  VotedSoFar.Value .. "/" .. AmountOfPlayers .. ")")
end)

Players.PlayerRemoving:Connect(function(Player)
	AmountOfPlayers = AmountOfPlayers - 1
	script.Parent.Text = ("Skip " .. "(" ..  VotedSoFar.Value .. "/" .. AmountOfPlayers .. ")")
end)

script.Parent.Text = ("Skip " .. "(" ..  VotedSoFar.Value .. "/" .. AmountOfPlayers .. ")")


game.ReplicatedStorage.FireVoteToClient.OnClientEvent:Connect(function()
	VotedSoFar.Value = VotedSoFar.Value + 1
	wait()
	script.Parent.Text = ("Skip " .. "(" ..  VotedSoFar.Value .. "/" .. AmountOfPlayers .. ")")
	VotedSoFar.Changed:Connect(function()
		if VotedSoFar.Value == AmountOfPlayers then
			print ("Added vote.")
			print ("Skipped")
		else
			print("Added vote.")
		end
	end)
end)

By the way, the “VotedSoFar” is an int value.

What should I do to fix this? Thanks, cal.

What part does it stop printing? Add prints at each step of the program so we can see where the problem may lie.

Sorry I don’t understand. Could you please clarify?

Remove the wait before game.Players.PlayerAdded on the server script.

1 Like

Alright, i will try this and I’ll let you know if it works. Thanks.

Thank you so much! This works now 100% You are a life-saver!

I noticed you have gui on the server as well. That is a big no no for tons of reasons.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.