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
 

Teleporting script help

Previous Thread :: Next Thread 
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
10 Aug 2012 03:03 AM
This is sort of a admin script but this is for a rp i'm doing.
What it does is when you say "Chaos Control", you get teleported to a random location (Once I get more Vector3 values but for now, it's only one).
The problem is that I have to test it in online mode since you can't use free chat in play solo mode on roblox studio. I tried it, went to play solo first to check the output and nothing showed.
This is when the problem started. I went to my game and typed it but nothing happened. It shows nothing in the output like I said before but I can't verify this as you can use free chat in testing on roblox studio.
Here's the script:

local isAdmin = {["Spongocardo"] = true, ["MarioKart333"] = true, ["j10adn"] = true}

function findPlayer(name)
for _, player in ipairs(game.Players:GetPlayers()) do
if player.Name:lower() == name:lower() then
return player
end
end
end

function onChatted(message, player)
if message:sub(1, 13) == "Chaos Control" and isAdmin[player.Name] then
game.Workspace[isAdmin].Torso.CFrame = CFrame.new(Vecotr3.new(-22.0000076, 26.6000004, -45))
end
end


game.Players.PlayerAdded:connect(function(player)
player.Chatted:connect(function(message) onChatted(message, player) end)
end)
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
10 Aug 2012 03:44 AM
Also, I tried a local script but it wouldn't work (Obviously due to my uber failing :P)
Gonna test it again and i'll get back.
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
10 Aug 2012 03:50 AM
"game.Workspace[isAdmin]"

There's your problem.

Also, you can start Play Solo and type this in in the command bar:

game.Players.LocalPlayer:SetSuperSafeChat(false)
Report Abuse
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
10 Aug 2012 04:03 AM
local isAdmin = {["Spongocardo"] = true, ["MarioKart333"] = true, ["j10adn"] = true}

function findPlayer(name)
for _, player in ipairs(game.Players:GetPlayers()) do
if player.Name:lower() == name:lower() then
return player
end
end
end

game.Players.PlayerAdded:connect(function(plr)
plr.Chatted:connect(function(message)
if message:sub(1, 13) == "Chaos Control" and isAdmin[player.Name] then
plr.Torso.CFrame = CFrame.new(-22.0000076, 26.6000004, -45)
end
end)
end)
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
10 Aug 2012 04:04 AM
Thanks for telling me how to turn off super safe chat in solo.
Anyway, would I use this instead of "game.Workspace[isAdmin]"?
game.Workspace:FindFirstChild(isAdmin)
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
10 Aug 2012 04:11 AM
@Iam
Fixed a little flaw in you're script and tested. Not working, still shows no output and nothing happens. This is why I don't trust the wiki.
Report Abuse
ArceusInator is not online. ArceusInator
Joined: 10 Oct 2009
Total Posts: 30553
10 Aug 2012 04:14 AM
Torso is not a valid member of Player

Use Player.Character.Torso instead
Report Abuse
IamAwesome777 is not online. IamAwesome777
Joined: 18 Jul 2011
Total Posts: 2640
10 Aug 2012 04:16 AM
Spongo, what did you change?
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
10 Aug 2012 04:24 AM
@Iam
There was another bracket needed on the last end.
@OP
Ok, will try
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
10 Aug 2012 04:39 AM
Got it working, used a script from the wiki and modified.
I was wrong about the wiki... I'm so sorry! *Crys*
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
10 Aug 2012 06:50 AM
Scratch that, I need just one more piece of help. You guys know when I said that I would have more places to teleport. Well, I am using a math.random function which varies the teleportation location. All it does is break the script! No output, no nothing...
Here's the script:
local admins = {"Spongocardo","j10adn","MarioKart333"}

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 == "Chaos control" and tableContains(admins, player.Name) then
local m = math.random(1,2)
if m == 1 then
player.Character.Torso.CFrame = CFrame.new(-22.0000076, 26.6000004, -45)
if m == 2 then
player.Character.Torso.CFrame = CFrame.new(-91.2000046, 26.5999851, -1.99999905)
end
end

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

Report Abuse
TehEpicFaic is not online. TehEpicFaic
Joined: 09 Apr 2010
Total Posts: 298
10 Aug 2012 07:06 AM
This part breaks the script:

if message == "Chaos control" and tableContains(admins, player.Name) then
local m = math.random(1,2)
if m == 1 then
player.Character.Torso.CFrame = CFrame.new(-22.0000076, 26.6000004, -45)
if m == 2 then
player.Character.Torso.CFrame = CFrame.new(-91.2000046, 26.5999851, -1.99999905)
end

You can't just place multiple "if"s and put one end for all of them.

You could do this, though, which is the proper way of it:

if message == "Chaos control" and tableContains(admins, player.Name) then
local m = math.random(1,2)
if m == 1 then
player.Character.Torso.CFrame = CFrame.new(-22.0000076, 26.6000004, -45)
elseif m == 2 then
player.Character.Torso.CFrame = CFrame.new(-91.2000046, 26.5999851, -1.99999905)
end
end

Remember, there's another end for the function but I didn't include it here.
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
10 Aug 2012 07:10 AM
You also messed up the connection line. Use this:

local admins = {"spongocardo" ,"j10adn", "mariokart333"};
local pos = {CFrame.new(-22, 26.6, -45), CFrame.new(-91.2, 26.6, -2)};

function isAdmin(nm)
for _, a in pairs(admins) do
if (a:lower() == nm:lower()) then return true; end
end
return false;
end

game.Players.ChildAdded:connect(function (newPlayer)
newPlayer.Chatted:connect(function (msg)
if (not isAdmin(newPlayer.Name)) then return; end
if (msg:lower():gsub(" ", "") == "chaoscontrol") then
if (not newPlayer.Character) then return; end
newPlayer.Character.Torso.CFrame = pos[math.random(1, #pos)];
end
end);
end);
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
10 Aug 2012 07:37 AM
Tried both dr01 and the OP and they don't work. I've added the necessary adjustments but it still doesn't work.
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
10 Aug 2012 08:04 AM
BUMP!
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
10 Aug 2012 08:05 AM
What did the output to mine say?
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
10 Aug 2012 08:10 AM
@dr01
It showed nothing in the output. That... is really spooky.
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
10 Aug 2012 08:10 AM
O.o
Try adding print itn to see how far it gets.
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
10 Aug 2012 08:12 AM
@dr01
So print(SCRIPT HERE)?
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
10 Aug 2012 08:15 AM
No, like this:

local admins = {"spongocardo" ,"j10adn", "mariokart333", "player"};
local pos = {CFrame.new(-22, 26.6, -45), CFrame.new(-91.2, 26.6, -2)};

function isAdmin(nm)
for _, a in pairs(admins) do
if (a:lower() == nm:lower()) then return true; end
end
return false;
end

game.Players.ChildAdded:connect(function (newPlayer)
print(newPlayer.Name.." has entered the game");
newPlayer.Chatted:connect(function (msg)
print(newPlayer.Name.." has said \""..msg.."\"");
if (not isAdmin(newPlayer.Name)) then return; end
print(newPlayer.Name.." is an admin");
if (msg:lower():gsub(" ", "") == "chaoscontrol") then
print("Said the correct message");
if (not newPlayer.Character) then return; end
print("Has a character");
newPlayer.Character.Torso.CFrame = pos[math.random(1, #pos)];
end
end);
end);
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
10 Aug 2012 08:21 AM
Worked, thanks!
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
10 Aug 2012 08:22 AM
Lol yw

I think I know why... If you were testing start server/player, then the name of your player was "player" but he wasn't on the admin list.
Report Abuse
Spongocardo is not online. Spongocardo
Joined: 06 Sep 2008
Total Posts: 2843
10 Aug 2012 08:22 AM
I tested on both online mode and start server/player.
Report Abuse
xXEliteDarkLordXx is not online. xXEliteDarkLordXx
Joined: 11 May 2010
Total Posts: 4
10 Aug 2012 08:44 AM
I thank you.This was really helpful.Play my game!!!
Report Abuse
Dr01d3k4 is not online. Dr01d3k4
Joined: 11 Oct 2007
Total Posts: 17916
10 Aug 2012 08:47 AM
^
lolwut
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 2Go to page: [1], 2 Next
 
 
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