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 » Scripters
Home Search
 

Re: onChatted script.. Taking what the player said and using it.

Previous Thread :: Next Thread 
cbhusker is not online. cbhusker
Joined: 07 Feb 2011
Total Posts: 517
21 Dec 2015 02:46 PM
Hey guys, it's Cbhusker. So right now, this script would work, minus one bit. but I'll get back to that in a minute...
So I have this script that I have and it is a tournament script, that selects the order people will fight in. Once an admin says 'run SFT' then it will go and make sure there is an even number of people playing. If there is not, it asks the admin which player will not play. and heres the dilemna... How do I take what the admin said to tell the script that.. As of now, I only know how to make the script do something if the admin says a specific thing. so how do I make the SCRIPT listen, then understand how to make it say that in the console.

*NOTE* I do not need help with telling the script HOW to make the player selected to not play, only (TAKING WHAT THE ADMIN SAYS AND TURNING THAT INTO THEY'RE NAME).




local admins = {"Player"}

function tableContains(t, value)
for _, v in pairs(t) do
if v == value then
return true
end
end
return false
end

function onChatted(message, player)
if message == "run SFT" and tableContains(admins, player.Name) then
for _, players in pairs(game.Players:GetPlayers()) do
local PlayerArray = {players.Name}
if #PlayerArray % 2 == 0 then

else
print("Odd number of players.. who will not participate?")
if message == "" and tableContains(admins, player.Name) then
print("Alright, "..THEIR_NAME_HERE.." will not compete.")
end
end
end
end
end

game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(message) onChatted(message, player) end)
end)


print("Hello World!")
Report Abuse
cbhusker is not online. cbhusker
Joined: 07 Feb 2011
Total Posts: 517
21 Dec 2015 02:51 PM
To clear things up..

for example:
The game may go like this::

Admin: "run SFT"

Game: "Odd number of players.. who will not participate?"

Admin: "Cbhusker"

Game: "Alright, Cbhusker will not compete."

(then the rest of the script will go on..



print("Hello World!")
Report Abuse
DrHaximus is not online. DrHaximus
Joined: 22 Nov 2011
Total Posts: 8410
21 Dec 2015 03:05 PM
something like this? (include your admin table/connect statements/tableContains


function do_SFT(p)

if p then
-- don't use player p
-- player obj
else
-- use everyone
end
-- blah
end

function is_player(n)
local p=game.Players:GetChildren()
for i=1,#p do
if(p[i].Name==n)then return true end
end return false
end

local expecting=false
function onChatted(message, player)
if message == "run SFT" and tableContains(admins, player.Name) then
if (game.Players.NumPlayers % 2 == 0) then do_SFT(nil)
else
expecting=true
end
elseif (expecting) and (is_player(message)) then
do_SFT(game.Players[message])
end
end
Report Abuse
DrHaximus is not online. DrHaximus
Joined: 22 Nov 2011
Total Posts: 8410
21 Dec 2015 03:06 PM
after the second do_SFT you probably want to set expecting back to false :p
Report Abuse
XIPokezIX is not online. XIPokezIX
Joined: 24 Sep 2015
Total Posts: 381
21 Dec 2015 03:29 PM
""if (game.Players.NumPlayers % 2 == 0) then do_SFT(nil)
else""


bish wet
Report Abuse
BrokenPhantom is not online. BrokenPhantom
Joined: 24 Aug 2012
Total Posts: 89
21 Dec 2015 03:36 PM
Well just pray to God in your time of need and he will deliver you from your worries.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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