|
| 12 Feb 2014 07:15 PM |
function FindPlayers() player1 = game.Players:FindFirstChild(players[math.random(1, #players)]) repeat player2 = game.Players:FindFirstChild(players[math.random(1, #players)]) wait() until player1 ~= player2 end
function Teleport() if player1 ~= nil and player2 ~= nil then player1.Character.Torso.CFrame = cframe1 player2.Character.Torso.CFrame = cframe2 end end
function ChangeCallout(val) callout.Value = val end
function GiveVote() for i = 1, #players do if players[i] ~= player1 and players[i] ~= player2 then vote = game.Workspace.Vote:clone() vote.Parent = players[i].PlayerGui vote.Player1Name.Value = player1.Name vote.Player2Name.Value = player2.Name player1vote.Value = 0 player2vote.Value = 0 end end end
function RemoveVote() for i = 1, #players do if players[i]:FindFirstChild("PlayerGui") then if players[i].PlayerGui:FindFirstChild("Vote") then players[i].PlayerGui.Vote:remove() end end end end
function Intermission() for i = 1, 30 do timeleft = 30 - i wait(1) callout.Value = "Intermission: "..timeleft end end
--Game Script
function Game() if #players > 2 then FindPlayers() callout.Value = player1.Name.." and "..player2.Name.." are about to battle!" wait (1) Teleport() wait(2) callout.Value = "Let the battle begin!" wait (2) for i = 1, 30 do wait(1) timeleft = 30-i callout.Value = player1.Name.." vs "..player2.Name.." Time: "..timeleft end wait(2) if player1 ~= nil and player2 ~= nil then ChangeCallout"Time to vote!" GiveVote() wait (15) RemoveVote() end if player1vote.Value > player2vote.Value then callout.Value = player1.Name.." Won!" wait(3) print("Game Over") Intermission() end if player1vote.Value < player2vote.Value then callout.Value = player2.Name.." Won!" wait(3) print("Game Over") Intermission() end if player1vote.Value == player2vote.Value then callout.Value = "There was a Tie!" wait(3) print("Game Over") Intermission() end end end
while wait() do Game() end |
|
|
| Report Abuse |
|
|
| |
|
Goulstem
|
  |
| Joined: 04 Jul 2012 |
| Total Posts: 7177 |
|
| |
|
Zulsoras
|
  |
| Joined: 10 Sep 2008 |
| Total Posts: 963 |
|
|
| 12 Feb 2014 08:03 PM |
player1 = game.Players:FindFirstChild(players[math.random(1, #players)]) Maybe try So what exactly is players[math.random(1, #players]) I do not see "players" as a variable, or see a array so..
|
|
|
| Report Abuse |
|
|
|
| 12 Feb 2014 09:13 PM |
Can I use
game.Players:GetChildren() for that?
( That's what I did ) |
|
|
| Report Abuse |
|
|
|
| 12 Feb 2014 09:16 PM |
All the output says is "String expected".
... Thanks Roblox. ._.' |
|
|
| Report Abuse |
|
|
|
| 13 Feb 2014 02:50 AM |
Your biggest problem is that you aren't declaring any of the variables you're using. Stuff like 'players', 'player1', 'player2', 'player1vote', 'player2vote' are all variables that you never defined. At the very least, declare them at the VERY top of your script, even if they have no current values. As for players, refresh it in the FindPlayers() function, GiveVote() function, and RemoveVote() function.
players = game.Players:GetPlayers() player1 = nil player2 = nil player1vote = workspace.Player1Vote player2vote = workspace.Player2Vote
function FindPlayers() players = game.Players:GetPlayers() --blah blah end
function GiveVote() players = game.Players:GetPlayers() --blah blah end
function RemoveVote() players = game.Players:GetPlayers() --blah blah end
|
|
|
| Report Abuse |
|
|