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.