How to add x2 vote map gamepass on my script, I put function “hasDoubleVoteGamePass” in server script already but i don’t know how to add this is server script and local script
Here my script in server script in ServerScriptService
-- Services
local wp = game:GetService("Workspace")
local plrs = game:GetService("Players")
local lighting = game:GetService("Lighting")
local rep = game:GetService("ReplicatedStorage")
local ts = game:GetService("TweenService")
local runs = game:GetService("RunService")
local debris = game:GetService("Debris")
local CollectionSS = game:GetService("CollectionService")
local mps = game:GetService("MarketplaceService")
-- Workspace Assets
local Lobby = wp:WaitForChild("Lobby", 5)
local Map = wp:WaitForChild("Map", 5)
local GameMusic = wp:WaitForChild("GameMusic", 5)
-- Assets
local assets = rep:WaitForChild("Assets", 5)
local events = assets:WaitForChild("Events", 5)
local lobbys = assets:WaitForChild("Lobbys", 5)
local maps = assets:WaitForChild("Maps", 5)
local Modules = assets:WaitForChild("Modules", 5)
local Values = rep:WaitForChild("Values", 5)
-- Events and BindableEvents
local TeamEvent = events:WaitForChild("TeamEvent", 5)
local Voted = events:WaitForChild("Voted", 5)
local VotingBegun = events:WaitForChild("VotingBegun", 5)
local VotingEnded = events:WaitForChild("VotingEnded", 5)
local DisableEvent = events:WaitForChild("DisableEvent", 5)
local UnequippedTool = events:WaitForChild("UnequippedTool", 5)
local LoadingEvent = events:WaitForChild("LoadingEvent", 5)
-- Valuable
local Timer = Values:WaitForChild("Timer", 5)
local GameRunning = Values:WaitForChild("GameRunning", 5)
local GameVoting = Values:WaitForChild("GameVoting", 5)
local SkipTime = Values:WaitForChild("skipTime", 5)
local LobbyIntermission = 90 -- 300
local MapIntermission = 600 -- 600
local voteIntermission = 10
local numMapVoting = 3
local doubleVoteGamePassId = 166803693 -- 166803693
local plrVotes = {}
-- Modules
local FormatTimer = require(Modules:WaitForChild("FormatTimer", 5))
local RemoveItems = require(Modules:WaitForChild("RemoveItems", 5))
--local PicItems = require(Modules:WaitForChild("PickItems", 5))
-- Functions
function hasDoubleVoteGamePass(plr)
if plr then
return mps:UserOwnsGamePassAsync(plr.UserId, doubleVoteGamePassId)
end
return false
end
function addVote(plr : Player, mapName : string)
plrVotes[plr] = mapName
Voted:FireAllClients(plrVotes)
end
function removePlayerVote(plr : Player)
plrVotes[plr] = nil
Voted:FireAllClients(plrVotes)
end
function loadLobby()
local newLobby = lobbys:GetChildren()[math.random(1, #lobbys:GetChildren())]:Clone()
local music = newLobby:WaitForChild("Music", 5)
newLobby.Parent = Lobby
GameMusic.SoundId = music.SoundId
GameMusic.MusicName.Value = music.MusicName.Value
GameMusic.OwnerMusic.Value = music.OwnerMusic.Value
GameMusic.TimePosition = 0
local Lobbyspawns = newLobby:WaitForChild("Spawns"):GetChildren()
local spawns = Lobbyspawns[math.random(1, #Lobbyspawns)]
for i, plr in pairs(plrs:GetPlayers()) do
local char = plr.Character or plr.CharacterAdded:Wait()
if char then
local hrp = char:WaitForChild("HumanoidRootPart", 5)
if hrp then
--hrp.CFrame = (spawns[i] and spawns[i].CFrame or spawns[i-#spawns]) + Vector3.new(0, 10, 0)
hrp.CFrame = spawns.CFrame + Vector3.new(0, 10, 0)
end
end
end
return newLobby
end
function loadMap(mapName : string)
local newMap = maps[mapName]:Clone()
local music = newMap:WaitForChild("Music", 5)
newMap.Parent = Map
GameMusic.SoundId = music.SoundId
GameMusic.MusicName.Value = music.MusicName.Value
GameMusic.OwnerMusic.Value = music.OwnerMusic.Value
GameMusic.TimePosition = 0
local Mapspawns = newMap:WaitForChild("Spawns"):GetChildren()
local spawns = Mapspawns[math.random(1, #Mapspawns)]
for i, plr in pairs(plrs:GetPlayers()) do
local char = plr.Character or plr.CharacterAdded:Wait()
if char then
local hrp = char:WaitForChild("HumanoidRootPart", 5)
if hrp then
--hrp.CFrame = (spawns[i] and spawns[i].CFrame or spawns[i-#spawns]) + Vector3.new(0, 10, 0)
hrp.CFrame = spawns.CFrame + Vector3.new(0, 10, 0)
end
end
end
return newMap
end
function removeLobby(lobby : Instance)
for i, v in pairs(CollectionSS:GetTagged("Effects")) do
if v.Parent == lighting then
v:Destroy()
end
end
lobby:Destroy()
for i, plr in pairs(plrs:GetPlayers()) do
plr:LoadCharacter()
end
end
function removeMap(map : Instance)
for i, v in pairs(CollectionSS:GetTagged("Effects")) do
if v.Parent == lighting then
v:Destroy()
end
end
map:Destroy()
for i, plr in pairs(plrs:GetPlayers()) do
plr:LoadCharacter()
end
end
function getPlayers(anchored, bool, val, ended)
for i, plr in pairs(plrs:GetPlayers()) do
local char = plr.Character or plr.CharacterAdded:Wait()
local leaderstats = plr:WaitForChild("leaderstats", 5)
local total_folder = plr:WaitForChild("Total_Folder", 5)
local money = total_folder:WaitForChild("Money", 5)
local kills = leaderstats:WaitForChild("Kills", 5)
local kill_streaks = leaderstats:WaitForChild("Kills Streak", 5)
if char then
if bool then
plr:LoadCharacter()
else
print("Not resetting.")
end
if ended then
money.Value += kills.Value * 2
else
print("Not ended")
end
kills.Value = val
kill_streaks.Value = val
char.HumanoidRootPart.Anchored = anchored
end
end
end
-- Coding Sections
Voted.OnServerEvent:Connect(addVote)
plrs.PlayerRemoving:Connect(removePlayerVote)
while true do
GameRunning.Value = false
local newLobby = loadLobby()
DisableEvent:FireAllClients(true)
LoadingEvent:FireAllClients(newLobby.Name, newLobby.Config.CreatedBy.Value, newLobby.Config.ImageId.Value)
local Countdown = LobbyIntermission
for i = Countdown, 0, -1 do
if not SkipTime.Value then
local min = (i - i%60)/60
i = i - min*60
Timer.Value = FormatTimer.format(min) .. ":" .. FormatTimer.format(i)
task.wait(1)
else
SkipTime.Value = false
Timer.Value = "00:00"
break
end
end
local mapsToVote = maps:GetChildren()
while #mapsToVote > numMapVoting do
table.remove(mapsToVote, math.random(1, #mapsToVote))
end
plrVotes = {}
VotingBegun:FireAllClients(mapsToVote)
--task.wait(voteIntermission)
Countdown = voteIntermission
for i = Countdown, 0, -1 do
local min = (i - i%60)/60
i = i - min*60
Timer.Value = FormatTimer.format(min) .. ":" .. FormatTimer.format(i)
task.wait(1)
end
local highesVotedFor = nil
local votes = {}
for i, map in pairs(mapsToVote) do
votes[map.Name] = 0
if i == 1 then
highesVotedFor = map.Name
end
end
for plr, vote in pairs(plrVotes) do
if votes[vote] then
votes[vote] += 1
if votes[highesVotedFor] < votes[vote] then
highesVotedFor = vote
end
end
end
VotingEnded:FireAllClients()
task.wait(1.5)
UnequippedTool:FireAllClients()
DisableEvent:FireAllClients(false)
removeLobby(newLobby)
--GameRunning.Value = true
local newMap = loadMap(highesVotedFor)
LoadingEvent:FireAllClients(newMap.Name, newMap.Config.CreatedBy.Value, newMap.Config.ImageId.Value)
getPlayers(true, false, 0, false)
Countdown = 5
for i = Countdown, 0, -1 do
local min = (i - i%60)/60
i = i - min*60
Timer.Value = FormatTimer.format(min) .. ":" .. FormatTimer.format(i)
task.wait(1)
end
DisableEvent:FireAllClients(true)
GameRunning.Value = true
getPlayers(false, true, 0, false)
Countdown = MapIntermission
for i = Countdown, 0, -1 do
if not SkipTime.Value then
local min = (i - i%60)/60
i = i - min*60
Timer.Value = FormatTimer.format(min) .. ":" .. FormatTimer.format(i)
if Timer.Value == "00:01" then
for i, plr in pairs(plrs:GetPlayers()) do
local char = plr.Character or plr.CharacterAdded:Wait()
if char then
UnequippedTool:FireAllClients()
RemoveItems.Remove(char)
RemoveItems.Remove(plr.Backpack)
end
end
end
task.wait(1)
else
SkipTime.Value = false
Timer.Value = "00:00"
break
end
end
UnequippedTool:FireAllClients()
GameRunning.Value = false
getPlayers(false, false, 0, true)
DisableEvent:FireAllClients(false)
task.wait(1)
removeMap(newMap)
end
And local script in gui
local plrs = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")
local ts = game:GetService("TweenService")
local mps = game:GetService("MarketplaceService")
local assets = rep:WaitForChild("Assets", 5)
local events = assets:WaitForChild("Events", 5)
local frame = script.Parent
local MapsContainer = frame:WaitForChild("MapsContainer", 5)
local mapTemplate = script:WaitForChild("MapFrame", 5)
local originalPosition = frame.Position
local Voted = events:WaitForChild("Voted", 5)
local VotingBegun = events:WaitForChild("VotingBegun", 5)
local VotingEnded = events:WaitForChild("VotingEnded", 5)
local doubleVoteGamePassId = 166803693 -- 166803693
local player = plrs.LocalPlayer
function hasDoubleVoteGamePass(plr)
if plr then
return mps:UserOwnsGamePassAsync(plr.UserId, doubleVoteGamePassId)
end
return false
end
VotingBegun.OnClientEvent:Connect(function(mapToVote)
for i, v in pairs(MapsContainer:GetChildren()) do
if v.ClassName == mapTemplate.ClassName then
v:Destroy()
end
end
local mapFrames = {}
for i, map in pairs(mapToVote) do
local newMapTemplate = mapTemplate:Clone()
newMapTemplate.Name = map.Name
newMapTemplate.MapName.Text = map.Name
newMapTemplate.NumVotes.Text = "0"
newMapTemplate.MapImage.Image = "rbxassetid://" .. map.Config.ImageId.Value
newMapTemplate.VoteButton.MouseButton1Click:Connect(function()
Voted:FireServer(map.Name)
end)
table.insert(mapFrames, newMapTemplate)
end
table.sort(mapFrames, function(a, b)
return a.Name < b.Name
end)
for _, mapFrame in pairs(mapFrames) do
mapFrame.Parent = MapsContainer
end
frame.Visible = true
local tween = ts:Create(frame, TweenInfo.new(1), {Position = UDim2.fromScale(0.5, 0.3)})
tween:Play()
end)
VotingEnded.OnClientEvent:Connect(function()
local tween = ts:Create(frame, TweenInfo.new(1), {Position = originalPosition})
tween:Play()
tween.Completed:Wait()
frame.Visible = false
end)
Voted.OnClientEvent:Connect(function(plrVotes)
if frame.Visible then
local votes = {}
for plr, vote in pairs(plrVotes) do
if not votes[vote] then
votes[vote] = 1
else
votes[vote] += 1
end
end
for i, mapFrame in pairs(MapsContainer:GetChildren()) do
if mapFrame.ClassName == mapTemplate.ClassName then
mapFrame.NumVotes.Text = (votes[mapFrame.Name] or 0)
end
end
end
end)
I built this topic and then waited for 4 days and no one answered, I want the answer for this topic