Surgo
|
  |
| Joined: 11 Jan 2011 |
| Total Posts: 2748 |
|
|
| 21 Jul 2014 09:49 PM |
So I'm making a script that when you say a number 10-35, that's how many kills player team will have to get to 'win'.
I was thinking that I would have to make a value in the script.
But what I don't know how to do it tell the script that a number 10-35 has been chosen. |
|
|
| Report Abuse |
|
|
blockoo
|
  |
| Joined: 08 Nov 2007 |
| Total Posts: 17202 |
|
|
| 21 Jul 2014 09:50 PM |
| You mean when someone chats that number in-game, that becomes how many kills are required? |
|
|
| Report Abuse |
|
|
blox6137
|
  |
| Joined: 23 Nov 2008 |
| Total Posts: 1109 |
|
|
| 21 Jul 2014 09:51 PM |
| I don't understand your question. |
|
|
| Report Abuse |
|
|
connor954
|
  |
| Joined: 24 Jul 2008 |
| Total Posts: 947 |
|
|
| 21 Jul 2014 09:52 PM |
| Well, first you have to set "who" can do this. |
|
|
| Report Abuse |
|
|
Surgo
|
  |
| Joined: 11 Jan 2011 |
| Total Posts: 2748 |
|
|
| 21 Jul 2014 09:57 PM |
All I've really figured out is this:
admins = {"Surgo"}
function isAdmin(name) for i,v in pairs(admins) do if name:lower() == v:lower() then return true end end return false end
local door=script.Parent game.Players.PlayerAdded:connect(function(p) if isAdmin(p.Name) then p.Chatted:connect(function(msg) if msg=="TEXT" then end end) end end) |
|
|
| Report Abuse |
|
|
Surgo
|
  |
| Joined: 11 Jan 2011 |
| Total Posts: 2748 |
|
|
| 21 Jul 2014 10:00 PM |
For the text part, I actually need it to be like "!load_TDM_10"
So I was thinking I would have to make it something like:
if msg=="!load_"..."TMD_"..."10" then
|
|
|
| Report Abuse |
|
|
UncleTaz
|
  |
| Joined: 19 Aug 2009 |
| Total Posts: 12795 |
|
|
| 21 Jul 2014 10:02 PM |
Okay first, the number of wins should be a IntValue so it can be accessed back and forth.
Then once the number is said, Use tostring(tonumber) and that number would be the value of the IntValue |
|
|
| Report Abuse |
|
|
Surgo
|
  |
| Joined: 11 Jan 2011 |
| Total Posts: 2748 |
|
|
| 21 Jul 2014 10:21 PM |
Don't understand this tonumber thing...
"Tries to convert its argument to a number. If the argument is already a number or a string convertible to a number, then tonumber returns this number; otherwise, it returns nil."
Like what |
|
|
| Report Abuse |
|
|
blox6137
|
  |
| Joined: 23 Nov 2008 |
| Total Posts: 1109 |
|
|
| 21 Jul 2014 10:24 PM |
var1 = 1 -- number var2 = "1" -- string
print(var1 .. var2)-- this would make error, as you cant concatenate numbers.
So, you would do: print(tonumber(var2) + var1), or print(tostring(var1) .. var2) |
|
|
| Report Abuse |
|
|
128GB
|
  |
| Joined: 17 Apr 2014 |
| Total Posts: 8056 |
|
|
| 21 Jul 2014 10:26 PM |
'var1 = 1 -- number var2 = "1" -- string
print(var1 .. var2)-- this would make error, as you cant concatenate numbers.'
No it doesn't error it outputs 11 |
|
|
| Report Abuse |
|
|
blox6137
|
  |
| Joined: 23 Nov 2008 |
| Total Posts: 1109 |
|
|
| 21 Jul 2014 10:27 PM |
| It produces an error in the IDE that I use, so it must be different with ROBLOX's. |
|
|
| Report Abuse |
|
|
blox6137
|
  |
| Joined: 23 Nov 2008 |
| Total Posts: 1109 |
|
|
| 21 Jul 2014 10:30 PM |
Just researched, and it's a bug with the IDE I use, not an error in the script. MY BAD. |
|
|
| Report Abuse |
|
|
Surgo
|
  |
| Joined: 11 Jan 2011 |
| Total Posts: 2748 |
|
|
| 21 Jul 2014 10:34 PM |
| Why am I adding? And WHAT am I adding? |
|
|
| Report Abuse |
|
|
Surgo
|
  |
| Joined: 11 Jan 2011 |
| Total Posts: 2748 |
|
| |
|
blox6137
|
  |
| Joined: 23 Nov 2008 |
| Total Posts: 1109 |
|
|
| 21 Jul 2014 10:43 PM |
| No, just ignore me and my comments. |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2014 10:49 PM |
You know you will need three things for this. First, you will need a variable to store the kill goal. Second, you will need a variable to store the kills made so far. Third, you know that you will have to connect to the Player.Chatted event. When the player chats, check their chat for a number. It should look like this:
local killsCurrent = 0 local killsGoal
local function onChatted(message) local goal = message:match "^(%d+)&" if not killsGoal and goal then killsGoal = goal end end
local function onDied() killsCurrent = killsCurrent + 1 end
local function onCharacterAdded(character) character:WaitForChild("Humanoid").Died:connect(onDied) end
local function onPlayerAdded(player) player.Chatted:connect(onChatted) player.CharacterAdded:connect(onCharacterAdded) end
game:GetService("Players").PlayerAdded:connect(onPlayerAdded) |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2014 10:52 PM |
tostring turns given argument into a string tonumber turns given arguments into a number ex:
local ex1='1' local ex2=1 print(type(ex1),type(ex2)) >String Number
ex1=tonumber(ex1) print(type(ex1)) >Number ex2=tostring(ex2) print(type(ex2)) >String
You can also use these with if statements to see if given arguments can be turned into a string or number. local s='Hello world!'
if tonumber(s) then print('It works!') else print("It isn't possible!") end
>
Nothing. Now, try changing the variable. If you make its contents numbers, it will print 'It works!'
local s='1'
if tonumber(s) then print('It works') else print("It isn't possible!") end
>It works! |
|
|
| Report Abuse |
|
|
Surgo
|
  |
| Joined: 11 Jan 2011 |
| Total Posts: 2748 |
|
|
| 21 Jul 2014 11:04 PM |
So if s='2'
Then Print would be: >It works! >It works!
??? |
|
|
| Report Abuse |
|
|
|
| 21 Jul 2014 11:13 PM |
By popular request, let me edit my code to do what he asked for:
ocal killsCurrent = 0 local killsGoal
local function onChatted(message) local goal = tonumber(message:match "^(%d+)&") if not killsGoal and goal and goal >= 10 and goal <= 35 then killsGoal = goal end end
local function onDied() killsCurrent = killsCurrent + 1 end
local function onCharacterAdded(character) character:WaitForChild("Humanoid").Died:connect(onDied) end
local function onPlayerAdded(player) player.Chatted:connect(onChatted) player.CharacterAdded:connect(onCharacterAdded) end
game:GetService("Players").PlayerAdded:connect(onPlayerAdded) |
|
|
| Report Abuse |
|
|