generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripting Helpers
Home Search
 

Re: Broken script "String Expected"

Previous Thread :: Next Thread 
iSwordFights is not online. iSwordFights
Joined: 07 Nov 2010
Total Posts: 358
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
iSwordFights is not online. iSwordFights
Joined: 07 Nov 2010
Total Posts: 358
12 Feb 2014 07:56 PM
Bump
Report Abuse
Goulstem is not online. Goulstem
Joined: 04 Jul 2012
Total Posts: 7177
12 Feb 2014 08:01 PM
Output please..
Report Abuse
Zulsoras is not online. 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
iSwordFights is not online. iSwordFights
Joined: 07 Nov 2010
Total Posts: 358
12 Feb 2014 09:13 PM
Can I use

game.Players:GetChildren() for that?

( That's what I did )
Report Abuse
iSwordFights is not online. iSwordFights
Joined: 07 Nov 2010
Total Posts: 358
12 Feb 2014 09:16 PM
All the output says is "String expected".



... Thanks Roblox. ._.'
Report Abuse
RobustPhysics is not online. RobustPhysics
Joined: 12 Jul 2012
Total Posts: 3064
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
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image