How do I make a voting gui and system like piggy?

So, this is the first time I made an entry in DevForum. So I just build a game inspired by piggy called “(Caty - Alpha - Roblox)” I need help how to make a voting map gui like a piggy? I’m still studying in script and newbie. Can you help me a little?

What are my goals:
1.Create a map voting system
2.Create a gamemode voting system
3.Make it select a player at random to be a piggy if a player’s gamemode has been selected

Your help is greatly appreciated, thank you!

Script:

1.IntermissionClient(LocalScript):

local timer = game.ReplicatedStorage.Info:WaitForChild("Timer")

local status = game.ReplicatedStorage.Info:WaitForChild("Status")

local camera = workspace.CurrentCamera

local intermission = script.Parent

local backBtn = intermission.backBtn

local menu = intermission.Parent.Menu

function countdown()

local player = game.Players.LocalPlayer

local character = player.Character or player.CharacterAdded:Wait()

intermission.Intermission.Text = status.Value .. ":" .. timer.Value

end

timer.Changed:Connect(countdown)

function backClient()

local TweenService = game:GetService("TweenService")

local camTween = TweenService:Create(camera, TweenInfo.new(1.2), {CFrame = workspace.Menu.Cam1.CFrame})

intermission.Visible = false

camTween:Play()

camTween.Completed:Wait()

menu.Visible = true

end

backBtn.MouseButton1Click:Connect(backClient)

2.MenuClient(LocalScript):

local buttons = script.Parent

local menu = buttons.Parent

local intermission = menu.Parent.Intermission

local shop = menu.Parent.Shop

local playBtn = buttons.PlayBtn

local shopBtn = buttons.ShopBtn

local timer = game.ReplicatedStorage.Info:WaitForChild("Timer")

local status = game.ReplicatedStorage.Info:WaitForChild("Status")

local function countdown()

for countdown=10, 0, -1 do

status.Value = "Intermission"

timer.Value = countdown

wait(1)

end

for countdown=10, 0, -1 do

status.Value = "Voting map"

timer.Value = countdown

intermission.Voting.Map.Visible = true

wait(1)

end

end

local camera = workspace.CurrentCamera

camera.CFrame = workspace.Menu.Cam1.CFrame

camera.CameraType = Enum.CameraType.Scriptable

camera.CameraSubject = workspace.Menu.Cam1

function playClient()

local TweenService = game:GetService("TweenService")

local camTween = TweenService:Create(camera, TweenInfo.new(1.2), {CFrame = workspace.Menu.Cam2.CFrame})

menu.Visible = false

camTween:Play()

camTween.Completed:Wait()

local players = game:GetService("Players")

local template = intermission.Players.Template:Clone()

template.Parent = intermission.Players

template.Visible = true

template.Name = players.Name

template.Image = players:GetUserThumbnailAsync(players.LocalPlayer.UserId, Enum.ThumbnailType.HeadShot, Enum.ThumbnailSize.Size100x100)

template.Username.Text = players.LocalPlayer.Name

intermission.Visible = true

countdown()

end

playBtn.MouseButton1Click:Connect(playClient)

function shopSystem()

local TweenService = game:GetService("TweenService")

local camTween = TweenService:Create(camera, TweenInfo.new(1.2), {CFrame = workspace.Menu.Cam3.CFrame})

local backTween = TweenService:Create(camera, TweenInfo.new(1.2), {CFrame = workspace.Menu.Cam1.CFrame})

menu.Visible = false

camTween:Play()

camTween.Completed:Wait()

shop.Visible = true

end

shopBtn.MouseButton1Click:Connect(shopSystem)

I need someone who pro at scripting tell me where should I edit the script to make it work.

3 Likes

I know how to do this.

--- Detect is players mode was selected
--- if it was do this
local plrs = Players:GetPlayers()
local chosen = math.random(1, #plrs)
for i = 1, #plrs do
if i == chosen then
---Do stuff, plrs[i] is the player that was chosen.
end
end

I might be able to help with the other ones later, but for now this is the only one that I can do off of the top of my head.

2 Likes

You should correct that to Players:GetPlayers()

3 Likes