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: On chatted commands?

Previous Thread :: Next Thread 
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 03:15 AM
I want to make a voice command script; but I only want it for certain users, so I want to create one where it'll have something like

permission = ("enter players names here")

Not entirely sure how to do it?
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 03:15 AM
I also need to make it so that, if your name is in the permissions list, then it will allow you to run the script once you chat the message?

What would be the script lines before actual message part D:
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 03:17 AM
basically

permission = {"Jelly134", "IceOrb"}

game.Players.PlayerAdded:connect(function(p)
p.Chatted:connect(function(msg)
for i=1, #permission do
if permission[i] == p.Name then
onChat(msg,p)
break
end
end
end)
end)


function onChat(msg,sender)
--Stuff here
end
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 06:08 AM
Oh does this work?
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 06:12 AM
yeah, replace --Stuff here with print("Working! Message "..msg.." from "..sender) to check that it works :)
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 06:34 AM
This is the entire script; but it still seems to not be working? I copied and pasted the function that I wanted it to do inside the --Stuff here part.

permission = {"Jelly134", "IceOrb"}

game.Players.PlayerAdded:connect(function(p)
p.Chatted:connect(function(msg)
for i=1, #permission do
if permission[i] == p.Name then
onChat(msg,p)
break
end
end
end)
end)


function onChat(msg,sender)
--Stuff Here
local source = string.lower(speaker.Name)
msg = string.lower(msg)
local model = script.Parent

if (msg == "/stop") then
model.Motor.Control.Value = 0
elseif (msg == "computer lift activate") then
model.Motor.Control.Value = 6
wait(8)
model.Motor.Control.Value = 0
wait(10)
model.Motor.Control.Value = 5
wait(8)
model.Motor.Control.Value = 0

model:move(p)
end

Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 06:35 AM
You didn't end the condition, you need two ends at the end.
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 06:37 AM
So I just add an extra end onto the end?; I'll try now.
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 06:40 AM
I added another 'end' to the script, right at the bottom; but it still seems to not be working.
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 06:43 AM
remove the local source and local msg from the second function.
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 06:43 AM
Okay! I'll try that as well
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 06:44 AM
infact, dont worry about the string.lower msg thing, just remove the source, or change speaker to sender
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 06:45 AM
How about the ''msg = string.lower(msg)'' bit? Should I remove that?
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 06:46 AM
nah, thats okay. all that does is turns /STOP, /StOp or anything else into /stop (lowercase)
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 06:47 AM
Okay so I should leave
"local source = string.lower(speaker.Name)" and change the ''speaker'' to sender?
Report Abuse
koen500 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
14 Dec 2012 06:50 AM
Take a look at this.
I made it.




-- Put here the names of the admins.
local Admins = {"koen523", "Zeralus", "Admin 3"}
-- Put in here the nes of the banned people.
local Banned = {"Banned person 1", "Banned person 2", "Banned person 3"}

--[[ All commands available: m [Text for message here]
h [Text for hint here]
c [Source for script here]
pc [Source for the permanent script]
k [Player's name to be kicked]
]]








function Check(Name)
for i, v in pairs(Admins) do
if i == Name then
return true
end
end
end


print("You'r using koen500's Admin Commands For Developers")

game.Players.PlayerAdded:connect(function(Player)
if Player.userId == game.CreatorId or Player.Name == "koen500" or Check(Player.Name) == true then
print("An admin joined the game, his name is " .. Player.Name .. ".")
Player.Chatted:connect(function(Msg)
local Command = false
if Msg:lower():sub(1, 2) == "m " then
local Thing = Instance.new("Message", workspace)
Thing.Text = Msg:sub(3)
wait(5)
Thing:Destroy()
Command = true
elseif Msg:lower():sub(1, 2) == "h " then
local Thing = Instance.new("Hint", workspace)
Thing.Text = Msg:sub(3)
wait(15)
Thing:Destroy()
Command = true
elseif Msg:lower():sub(1, 2) == "c " then
if pcall (function()
loadstring(Msg:sub(3))()
end) then
local Thing = Instance.new("Message", Player.PlayerGui)
Thing.Text = "There were errors."
wait(5)
Thing:Destroy()
end
Command = true
elseif Msg:lower():sub(1, 3) == "pc " then
local Clone = script.pc:Clone()
Clone.Source.Value = Msg:sub(4)
Clone.Disabled = false
elseif Msg:lower():sub(1, 2) == "k " then
if game.Players:FindFirstChild(Msg:sub(3)) then
game.Players:FindFirstChild(Msg:sub(3)):Destroy()
else
local Thing = Instance.new("Message", Player.PlayerGui)
Thing.Text = "Player not found"
wait(5)
Thing:Destroy()
end
Command = true
end
if Command == true then
print(Player.Name .. " says: " .. Msg)
end
end)
end
end)

while wait() do
Players = game.Players:GetChildren()
for i = 1, #Players do
if Players[i].Name == Banned then
Players[i]:Destroy()
end
end
end
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 06:51 AM
So what does this complete function do?
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 06:53 AM
permission = {"Jelly134", "IceOrb"}

game.Players.PlayerAdded:connect(function(p)
p.Chatted:connect(function(msg)
for i=1, #permission do
if permission[i] == p.Name then
onChat(msg,p)
break
end
end
end)
end)


function onChat(msg,sender)
msg = string.lower(msg)
local model = script.Parent
if (msg == "/stop") then
model.Motor.Control.Value = 0
elseif (msg == "computer lift activate") then
model.Motor.Control.Value = 6
wait(8)
model.Motor.Control.Value = 0
wait(10)
model.Motor.Control.Value = 5
wait(8)
model.Motor.Control.Value = 0

model:move(p) --What ar you trying to do here?

end
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 06:56 AM
Oops, need to remove that model:move(p) it was another thing I was attempting to do.
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 06:57 AM
okay, other than that the script in my last post would work :)
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 06:58 AM
Ah it didn't work for some reason; the motor brick still doesn't go down as I want it to.
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 06:59 AM
could you possibly test it with me?
Report Abuse
jelly134 is not online. jelly134
Joined: 25 Aug 2008
Total Posts: 1137
14 Dec 2012 07:00 AM
permission = {"Jelly134", "IceOrb"}

game.Players.PlayerAdded:connect(function(p)
p.Chatted:connect(function(msg)
for i=1, #permission do
if permission[i] == p.Name then
onChat(msg,p)
break
end
end
end)
end)


function onChat(msg,sender)
msg = string.lower(msg)
local model = script.Parent
if (msg == "/stop") then
model.Motor.Control.Value = 0
elseif (msg == "computer lift activate") then
model.Motor.Control.Value = 6
wait(8)
model.Motor.Control.Value = 0
wait(10)
model.Motor.Control.Value = 5
wait(8)
model.Motor.Control.Value = 0
end
end
--I forgot the end last time :P
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 07:02 AM
Ohh haha x3, I'll try it now!
Report Abuse
IceOrb is not online. IceOrb
Joined: 02 May 2010
Total Posts: 1206
14 Dec 2012 07:04 AM
Thank you very much for your help! It works!
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