Oliver00
|
  |
| Joined: 20 Feb 2009 |
| Total Posts: 38 |
|
|
| 27 Mar 2013 11:38 PM |
If this is confusing just tell me. So I made 3 tele pads (telepad 1, telepad 2, telepad 3). So what I want is to make a tele pad that when you touch it you can either teleport to telepad 2 or telepad 3. I want the script to say if you touch telepad 1 pick a random number between 1 and 20. If that number is 15 then teleport to telepad 3. If the number is anything else besides 15 then teleport to telepad 2. How do I do that? I've tried making a script like that but it doesn't work:
local Teleporter1 = Workspace.One local Teleporter2a = Workspace.Two local Teleporter2b = Workspace.Three local Chance = 15 math.randomseed(tick()) Teleporter1.Touched:connect(function(Part) if Part.Parent:FindFirstChild("Humanoid") then if math.random(1,15) == 15 then Part.Parent.Torso.CFrame = Teleporter2b.CFrame else Part.Parent.Torso.CFrame = Teleporter2a.CFrame end end) |
|
|
| Report Abuse |
|
|
|
| 27 Mar 2013 11:39 PM |
You're missing an end.
(╯°□°)> KMXD |
|
|
| Report Abuse |
|
|
|
| 27 Mar 2013 11:42 PM |
^ Here is it fixed:
local Teleporter1 = Workspace.One local Teleporter2a = Workspace.Two local Teleporter2b = Workspace.Three local Chance = 15
math.randomseed(tick())
Teleporter1.Touched:connect(function(Part) if Part.Parent:FindFirstChild "Humanoid" then if math.random(1,chance) == 1 then Part.Parent.Torso.CFrame = Teleporter2b.CFrame else Part.Parent.Torso.CFrame = Teleporter2a.CFrame end end end) |
|
|
| Report Abuse |
|
|
|
| 27 Mar 2013 11:43 PM |
Also, if you're using math.random between 1 and x, you don't even need to include the 1.
(╯°□°)> KMXD |
|
|
| Report Abuse |
|
|
Oliver00
|
  |
| Joined: 20 Feb 2009 |
| Total Posts: 38 |
|
|
| 28 Mar 2013 12:06 AM |
@ArbiterOfDeath Your script doesn't work. |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2013 12:09 AM |
Capitalize 'chance' in the math.random line.
(╯°□°)> KMXD |
|
|
| Report Abuse |
|
|
Oliver00
|
  |
| Joined: 20 Feb 2009 |
| Total Posts: 38 |
|
|
| 28 Mar 2013 12:46 AM |
still doesn't work. I changed a few things here is what I have.
local Teleporter1 = Workspace.telepads.Teleporter 1 local Teleporter2a = Workspace.telepads.Teleporter 2a local Teleporter2b = Workspace.telepads.Teleporter 2b local Chance = 15
math.randomseed(tick())
Teleporter1.Touched:connect(function(Part) if Part.Parent:FindFirstChild "Humanoid" then if math.random(1,chance) == 1 then Part.Parent.Torso.CFrame = Teleporter2b.CFrame else Part.Parent.Torso.CFrame = Teleporter2a.CFrame end end end) |
|
|
| Report Abuse |
|
|
|
| 28 Mar 2013 02:33 PM |
No, you should capitalize the "c" in "chance", as that was Arbiter's variable; "Chance".
if math.random(Chance) == 1 then --You also don't need to put a 1 there
(╯°□°)> KMXD
|
|
|
| Report Abuse |
|
|
Oliver00
|
  |
| Joined: 20 Feb 2009 |
| Total Posts: 38 |
|
|
| 29 Mar 2013 04:28 PM |
still doesn't work. This is what I have.
local Teleporter1 = Workspace.telepads.Teleporter 1 local Teleporter2a = Workspace.telepads.Teleporter 2a local Teleporter2b = Workspace.telepads.Teleporter 2b local Chance = 15
math.randomseed(tick())
Teleporter1.Touched:connect(function(Part) if Part.Parent:FindFirstChild "Humanoid" then if math.random(Chance) == 1 then Part.Parent.Torso.CFrame = Teleporter2b.CFrame else Part.Parent.Torso.CFrame = Teleporter2a.CFrame end end end)
That script does not work. |
|
|
| Report Abuse |
|
|
|
| 29 Mar 2013 04:30 PM |
There shouldn't be spaces in the top variables. If there really is:
local Teleporter1 = Workspace.telepads["Teleporter 1"] local Teleporter2a = Workspace.telepads["Teleporter 2a"] local Teleporter2b = Workspace.telepads["Teleporter 2b"]
(╯°□°)> KMXD |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 29 Mar 2013 04:33 PM |
hm, seems like it can break. According to warning from wiki.roblox.com
Tell me what will happen when you step on each of the 3 teleporters, and I'll try make a script that should fit your purpose.
- As, The concept of Roblox = ROB-LOX (Idk what Lox means, could be people.) o3o |
|
|
| Report Abuse |
|
|
Oliver00
|
  |
| Joined: 20 Feb 2009 |
| Total Posts: 38 |
|
| |
|
Oliver00
|
  |
| Joined: 20 Feb 2009 |
| Total Posts: 38 |
|
|
| 30 Mar 2013 12:53 AM |
this is what I have
local Teleporter1 = Workspace.telepads["Teleporter 1"] local Teleporter2a = Workspace.telepads["Teleporter 2a"] local Teleporter2b = Workspace.telepads["Teleporter 2b"] local Chance = 15
math.randomseed(tick())
Teleporter1.Touched:connect(function(Part) if Part.Parent:FindFirstChild "Humanoid" then if math.random(Chance) == 1 then Part.Parent.Torso.CFrame = Teleporter2b.CFrame else Part.Parent.Torso.CFrame = Teleporter2a.CFrame end end end) |
|
|
| Report Abuse |
|
|
crouton04
|
  |
| Joined: 07 Jul 2010 |
| Total Posts: 4459 |
|
|
| 30 Mar 2013 12:59 AM |
| Im confused, whats math.randomseed? |
|
|
| Report Abuse |
|
|
Oliver00
|
  |
| Joined: 20 Feb 2009 |
| Total Posts: 38 |
|
|
| 30 Mar 2013 01:22 AM |
| It picks a random number and if the number is 15 then teleport to teleporter2b if it's anything else then teleport to teleporter2a |
|
|
| Report Abuse |
|
|
crouton04
|
  |
| Joined: 07 Jul 2010 |
| Total Posts: 4459 |
|
|
| 30 Mar 2013 11:46 AM |
| What are you talking about, math.randomseed(tick()) wont pick anumber from 1-15. |
|
|
| Report Abuse |
|
|
|
| 30 Mar 2013 12:42 PM |
| Randomseed only changes the first value in the sequence of "random numbers." It's used to start the random sequence from a number never used before. |
|
|
| Report Abuse |
|
|
Oliver00
|
  |
| Joined: 20 Feb 2009 |
| Total Posts: 38 |
|
|
| 30 Mar 2013 03:56 PM |
| the point is when I touch the tele nothing happens. |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 30 Mar 2013 05:49 PM |
Okay, since you're completely ignoring my post, I will make a theory:
You have a model with 3 teleporters. The teleporter should teleport you to the next teleport, so that we had a "circle" of teleporters... ok, a circle of 3 teleporters. That would teleport to each other.
If the teleporters were named A, B and C, then A would teleport you to B, B would teleport you to C and C would teleport you to A. Right?
So, your structure is like this: Model > Script > TeleporterA > TeleporterB > TeleporterC
I will now try write down a script that should work. It will not be all that insane that it's only teleporting you at a random condition, but it won't "loop teleport" you.
Put this in the "Script" object, as shown in the structure above ^ ------------------------------------------------------------------------------------------------- local model = script.Parent teles = {model.TeleporterA, model.TeleporterB, model.TeleporterC} local deb = {}
function r() return math.random() - 0.5 end -- utility :/
for k,t in pairs(teles) do t.Touched:connect(function(hit) if hit and hit.Parent and game:service("Players"):GetPlayerFromCharacter(hit.Parent) then if not deb[t] and teles[(k % #teles) + 1] then deb[t] = true hit.Parent:MoveTo(teles[(k % #teles) + 1].Position + Vector3.new(r(), 3 + r(), r()) * 2) wait(2) deb[t] = nil end end end) end -------------------------------------------------------------------------------------------------
Hope it'll work, otherwise tell me! Remember to make the objects before running the script, as the opposite order would make me puke. Literally.
- As, shaking with a puke-bag. Please, please don't... |
|
|
| Report Abuse |
|
|
Oliver00
|
  |
| Joined: 20 Feb 2009 |
| Total Posts: 38 |
|
|
| 01 Apr 2013 01:17 AM |
| still doesn't work. Also that's not what I want. I don't want a circle I only put the script in one teleport because it's a one way tele. The way it works is I though teleport A and it either teleports me to teleport B or teleport C. It also doesn't random choose whether to teleport to teleporter B or teleporter C it picks a random number between 1-20 and if that number is 15 then it teleports me to teleporter C. If the number is anything else then it teleports me to teleporter B. Do you understand now? |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 01 Apr 2013 06:51 AM |
Okay, same structure as before...
-------------------------------------------------------------------------
local model = script.Parent local teles = {model.TeleporterB, model.TeleporterC} local main = model.TeleporterA local deb = {}
function r() return math.random() - 0.5 end -- utility :/
main.Touched:connect(function(hit) if hit and hit.Parent and game:service("Players"):GetPlayerFromCharacter(hit.Parent) then local chance = math.random(1, 20) -- I like the 1 :P local gotTele = (chance == 15 and 2) or 1 if not deb[t] and teles[gotTele] then deb[t] = true hit.Parent:MoveTo(teles[gotTele].Position + Vector3.new(r() * 2, 3 + r(), r() * 2)) wait(2) deb[t] = nil end end end)
-------------------------------------------------------------------------
I hope this one is working. Whatever the problem could've been. - As, buy my trollin' shirt, 1 r$ http://www.roblox.com/--item?id=111435301 |
|
|
| Report Abuse |
|
|
Oliver00
|
  |
| Joined: 20 Feb 2009 |
| Total Posts: 38 |
|
|
| 01 Apr 2013 05:27 PM |
| still doesn't work. By doesn't work I mean it doesn't teleport me at all. |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 02 Apr 2013 02:50 AM |
Okay, I fixed the bug.
Also, it would help a lot if you posted any errors you find in the Output window related to the script while using it, so I won't have to make a model and insert the script J:
-------------------------------------------- Structure:
Model > Script > TeleporterA > TeleporterB > TeleporterC
-------------------------------------------- Script:
local model = script.Parent local teles = {model.TeleporterB, model.TeleporterC} local main = model.TeleporterA local deb
function r() return math.random() - 0.5 end -- utility :/
main.Touched:connect(function(hit) if hit and hit.Parent and game:service("Players"):GetPlayerFromCharacter(hit.Parent) then local chance = math.random(1, 20) -- I like the 1 :P local gotTele = (chance == 15 and 2) or 1 if not deb and teles[gotTele] then deb = true hit.Parent:MoveTo(teles[gotTele].Position + Vector3.new(r() * 2, 3 + r(), r() * 2)) wait(0.1) deb = nil end end end) --------------------------------------------
- As, 51% power. |
|
|
| Report Abuse |
|
|
Oliver00
|
  |
| Joined: 20 Feb 2009 |
| Total Posts: 38 |
|
|
| 03 Apr 2013 05:59 PM |
| still doesn't teleport when I touch it. |
|
|
| Report Abuse |
|
|
As8D
|
  |
| Joined: 24 Dec 2009 |
| Total Posts: 2907 |
|
|
| 04 Apr 2013 04:18 AM |
Do you want me to turn it into a model??!!?!?!?!?! I have even tested it! THIS IS SERVICE! D: Praise my inventions and owe me a donut, slaves of evil.
- As, "This Is Service" is aqually a catchphrase! |
|
|
| Report Abuse |
|
|