Here are the scripts why doesn’t it change HasVoted and why can’t I vote again?
VoteMain:
local ToggleVoteEvent = game.ReplicatedStorage.ToggleVoteEvent
local Option1 = game.ReplicatedStorage.VoteValues.Chapter1
local Option2 = game.ReplicatedStorage.VoteValues.Chapter2
game.ReplicatedStorage.RoundInfo.Status:GetPropertyChangedSignal("Value"):Connect(function()
print("1")
if game.ReplicatedStorage.RoundInfo.Status.Value == "Intermission" then
print("2")
wait(8)
ToggleVoteEvent:FireAllClients(true)
wait(15)
ToggleVoteEvent:FireAllClients(false)
if Option1.Value > Option2.Value then
print("3")
game.ReplicatedStorage.RoundInfo.Chapter.Value = "Chapter1"
game.ReplicatedStorage.ChapterValues.spawn.Value = "spawn2"
game.ReplicatedStorage.ChapterValues.CutsceneChapter.Value = "Chapter1"
elseif Option2.Value > Option1.Value then
print("4")
game.ReplicatedStorage.RoundInfo.Chapter.Value = "Chapter2"
game.ReplicatedStorage.ChapterValues.spawn.Value = "spawn3"
game.ReplicatedStorage.ChapterValues.CutsceneChapter.Value = "Chapter2"
elseif Option1.Value == Option2.Value then
local random = math.random(1,2)
if random == 1 then
game.ReplicatedStorage.RoundInfo.Chapter.Value = "Chapter1"
game.ReplicatedStorage.ChapterValues.spawn.Value = "spawn2"
game.ReplicatedStorage.ChapterValues.CutsceneChapter.Value = "Chapter1"
else
game.ReplicatedStorage.RoundInfo.Chapter.Value = "Chapter2"
game.ReplicatedStorage.ChapterValues.spawn.Value = "spawn3"
game.ReplicatedStorage.ChapterValues.CutsceneChapter.Value = "Chapter2"
end
end
end
end)
Vote Server:
local AddVoteEvent = game.ReplicatedStorage.AddVoteEvent
local Option1 = game.ReplicatedStorage.VoteValues.Chapter1
local Option2 = game.ReplicatedStorage.VoteValues.Chapter2
AddVoteEvent.OnServerEvent:Connect(function(Player,Option)
if Option == 1 then
Option1.Value += 1
elseif Option == 2 then
Option2.Value += 1
end
end)
ToggleGui
local ToggleVoteEvent = game.ReplicatedStorage.ToggleVoteEvent
local Frame = script.Parent
ToggleVoteEvent.OnClientEvent:Connect(function(Value)
if Value == true then
Frame.Visible = true
elseif Value == false then
Frame.Visible = false
end
end)
VoteClient:
local AddVoteEvent = game.ReplicatedStorage.AddVoteEvent
local player = game.Players.LocalPlayer
local HasVoted = false
local Button1 = script.Parent.Chapter1
local Button2 = script.Parent.Chapter2
local Option1 = game.ReplicatedStorage.VoteValues.Chapter1
local Option2 = game.ReplicatedStorage.VoteValues.Chapter2
local function Vote(Button,Option)
if HasVoted == false and game.ReplicatedStorage.RoundInfo.Status.Value ~= "Game" then
HasVoted = true
Button.BackgroundColor3 = Color3.fromRGB(0,97,145)
AddVoteEvent:FireServer(Option)
print(HasVoted)
game.ReplicatedStorage.ResetVote:FireServer(HasVoted)
end
end
Button1.MouseButton1Click:Connect(function()
Vote(Button1, 1)
end)
Button2.MouseButton1Click:Connect(function()
Vote(Button2,2)
end)
Option1.Changed:Connect(function()
Button1.VoteCount.Text = Option1.Value
end)
Option2.Changed:Connect(function()
Button2.VoteCount.Text = Option2.Value
end)