Sorry about my english grammar
-
I am working about map voting pad system but i don’t know how to put my voting x2 gamepass in my script
-
Picture of map voting model
-
I tried every but is a lot of bug on map voting pad idk how to fix it
After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!
Here MapVotingScript module
local plrs = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")
local module = {}
local status = game.ReplicatedStorage.Values.Status
local mapVotes = {}
local Assets = rep:WaitForChild("Assets")
local maps = Assets:WaitForChild("Maps")
local Events = rep:WaitForChild("Events")
local Values = rep:WaitForChild("Values")
local x2VotesID = 166803693
-- Example:
--mapVotes = {
---1;
--Desert;
--players = {
--AnoB0t;
--}
--}
local VotingPads = workspace:WaitForChild("VotingPads")
local skipTime = Values:WaitForChild("skipTime")
local function givePerk(plr)
local plrSettings = plr:WaitForChild("PlayerSettings")
if not plrSettings then return end
plrSettings.multiplierVotes.Value = 2
end
Events.PlaceVote.OnServerEvent:Connect(function(player, padNumber)
-- Check if player already voted
for i,v in pairs(mapVotes) do
for x,plr in pairs(v.players) do
if plr == player.UserId then
table.remove(v.players, x)
break
end
end
end
-- Place vote
for i,v in pairs(mapVotes) do
-- Check which player voted on
if v.order == padNumber then
table.insert(v.players, player.UserId)
end
end
end)
function getMap()
local randomMap = maps:GetChildren()[math.random(1,#maps:GetChildren())]
for i,v in pairs(mapVotes) do
-- if map exists in the table
if v.name == randomMap.Name then
return getMap()
end
end
return randomMap.Name
end
function module.MapVoting(dur)
-- Start the voting system
mapVotes = {}
for i,v in pairs(VotingPads:GetChildren()) do
table.insert(mapVotes,{order = tonumber(v.Name:match("%d+")); name = getMap(); players = {};})
v.Color = Color3.fromRGB(255,0,0)
end
Values.MapVotingProgress.Value = true
local start = tick()
while wait() do
-- Check if number of seconds passed the maxDuration
if not skipTime.Value then
if tick()-start >= dur then break end
status.Value = math.floor(dur-(tick()-start))
-- Update the pads
for i,v in pairs(VotingPads:GetChildren()) do
local votes,mapName
for x,map in pairs(mapVotes) do
-- Check if the order match the pads number
if map.order == tonumber(v.Name:match("%d+")) then
votes = #map.players
mapName = map.name
break
end
end
v.Display.SurfaceGui.MapName.Text = mapName
v.Display.SurfaceGui.VoteCount.Text = votes
end
else
skipTime.Value = false
status.Value = 0
break
end
end
Values.MapVotingProgress.Value = false
-- Sort the votes, we get the winner
table.sort(mapVotes, function(a,b) return #a.players > #b.players end)
for i,v in pairs(VotingPads:GetChildren()) do
v.Color = Color3.fromRGB(80,80,80)
end
--status.Value = mapVotes[1].name.." was chosen!"
wait(3)
return maps:FindFirstChild(mapVotes[1].name)
end
return module
local script
local plrs = game:GetService("Players")
local rep = game:GetService("ReplicatedStorage")
local runs = game:GetService("RunService")
local ts = game:GetService("TweenService")
local player = plrs.LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local hrp = char:WaitForChild("HumanoidRootPart", 5)
local currentVote = nil
local VotingPads = workspace:WaitForChild("VotingPads")
local Assets = rep:WaitForChild("Assets")
local Events = rep:WaitForChild("Events")
local Values = rep:WaitForChild("Values")
local Maps = Assets:WaitForChild("Maps")
--script.Parent:WaitForChild("INTRO").Enabled = true
-- When a voting starts or ends
Values.MapVotingProgress:GetPropertyChangedSignal("Value"):Connect(function()
currentVote = nil
end)
runs.RenderStepped:Connect(function()
-- Check if voting started
if Values.MapVotingProgress.Value then
local raycastParams = RaycastParams.new()
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {char:GetChildren()}
local result = workspace:Raycast(hrp.CFrame.p, Vector3.new(0,-10000,0),raycastParams)
if result then
local object = result.Instance
-- If player touch the pad
if object and object.Name:match("Pad") then
local padNumber = tonumber(object.Name:match("%d+"))
Events.PlaceVote:FireServer(padNumber)
if currentVote == nil or currentVote ~= padNumber then
local sfx = Instance.new("Sound",script.Parent)
sfx.SoundId = "rbxassetid://4676738150"
sfx.Volume = 1;
sfx:Play()
task.spawn(function()
task.wait(1)
sfx:Destroy()
end)
currentVote = padNumber
for i,v in pairs(VotingPads:GetChildren()) do
v.Color = Color3.fromRGB(255,0,0)
end
Events:WaitForChild("TweenPads"):FireServer(object)
object.Color = Color3.fromRGB(255,255,0)
end
end
end
end
end)
I get this script from youtube channel @Anobot I must thank you so him