Advertisement
Joemamahacks

Murder Mystery Voting System

Apr 26th, 2024
648
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Lua 1.45 KB | None | 0 0
  1. local mapVotes = {}
  2. local maps = {"Map1", "Map2", "Map3"}
  3.  
  4. game.Players.PlayerAdded:Connect(function(player)
  5.     player.CharacterAdded:Connect(function(character)
  6.         local humanoid = character:WaitForChild("Humanoid")
  7.         local rootPart = character:WaitForChild("HumanoidRootPart")
  8.  
  9.         for i, mapName in ipairs(maps) do
  10.             local mapBrick = workspace:FindFirstChild(mapName)
  11.             if mapBrick then
  12.                 mapBrick.Touched:Connect(function(otherPart)
  13.                     if otherPart.Parent == humanoid.Parent then
  14.                         mapVotes[mapName] = (mapVotes[mapName] or 0) + 1
  15.                         print(player.Name .. " voted for " .. mapName)
  16.                     end
  17.                 end)
  18.             end
  19.         end
  20.     end)
  21. end)
  22.  
  23. --------------------------Use this script if you want the player to be teleported to the map that won--------------------------
  24.  
  25. local ReplicatedStorage = game:GetService("ReplicatedStorage")
  26. local Players = game:GetService("Players")
  27.  
  28. local mapVotes = {}
  29. local maps = {"Map1", "Map2", "Map3"}
  30.  
  31.  
  32. local winningMap = "Map1"
  33.  
  34.  
  35. for _, player in ipairs(Players:GetPlayers()) do
  36.     local character = player.Character
  37.     if character then
  38.         local spawnLocation = ReplicatedStorage.Maps:FindFirstChild(winningMap)
  39.         if spawnLocation then
  40.             character:SetPrimaryPartCFrame(spawnLocation.CFrame + Vector3.new(0, 5, 0))
  41.         end
  42.     end
  43. end
  44.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement