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: Haaaaalp :P

Previous Thread :: Next Thread 
Monkey1234567890123 is not online. Monkey1234567890123
Joined: 24 Oct 2009
Total Posts: 327
23 Jul 2012 09:28 PM
I am trying to make it so that a teleporter randomly sends you to one of 7 bricks (positions)... would i use math.random()? If not what would i use?(i know the code just not the random brick(position) part)
Report Abuse
UFAIL2 is not online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
23 Jul 2012 09:40 PM
If the parts are all in the same model, do something like this. This probably won't work, but you get the idea.

Player:MoveTo(Model:GetChildren(math.random(#Model:GetChildren()))
Report Abuse
Monkey1234567890123 is not online. Monkey1234567890123
Joined: 24 Oct 2009
Total Posts: 327
23 Jul 2012 09:41 PM
I'll test it thanks...
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
23 Jul 2012 09:43 PM
Player.Character:MoveTo(Model:GetChildren()[math.random(1,#Model:GetChildren())].Position + Vector3.new(0,6,0))
Report Abuse
UFAIL2 is not online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
23 Jul 2012 09:45 PM
Little mistake

Player:MoveTo(Model:GetChildren[math.random(#Model:GetChildren())])
Report Abuse
UFAIL2 is not online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
23 Jul 2012 09:46 PM
I need to proof-read.

Player:MoveTo(Model:GetChildren()[math.random(#Model:GetChildren())])
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
23 Jul 2012 09:46 PM
^*Player.Character-
Report Abuse
UFAIL2 is not online. UFAIL2
Joined: 14 Aug 2010
Total Posts: 6905
23 Jul 2012 09:48 PM
Thanks for pointing out my mistake.
Report Abuse
Monkey1234567890123 is not online. Monkey1234567890123
Joined: 24 Oct 2009
Total Posts: 327
23 Jul 2012 09:52 PM
Here's where I'm at.....



Model = game.Workspace.SpawnBricks

function touched(hit)
local Player = hit.Parent
if Player ~= nil then
Player:MoveTo(Model:GetChildren(math.random(#Model:GetChildren())))
end
end

script.Parent.Touched:connect(touched)

Output:22:50:45 - Unable to cast Array to Vector3
22:50:45 - Script "Workspace.Spawn House.Spawn?.Head.Script", Line 6
22:50:45 - stack end
22:50:45 - Disconnected event because of exception
Report Abuse
Monkey1234567890123 is not online. Monkey1234567890123
Joined: 24 Oct 2009
Total Posts: 327
23 Jul 2012 09:53 PM
herp i neglected to look at the recent post ignore that last post....
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
23 Jul 2012 09:54 PM
Usar mi linea.
Report Abuse
Monkey1234567890123 is not online. Monkey1234567890123
Joined: 24 Oct 2009
Total Posts: 327
23 Jul 2012 09:56 PM
what?
Report Abuse
Monkey1234567890123 is not online. Monkey1234567890123
Joined: 24 Oct 2009
Total Posts: 327
23 Jul 2012 10:01 PM
what about this:


Model = game.Workspace.SpawnBricks

function touched(hit)
local Player = hit.Parent
if Player ~= nil then
Player.Character:MoveTo(Model:GetChildren()[math.random(#Model:GetChildren())])
end
end

script.Parent.Touched:connect(touched)


Output:22:59:34 - Character is not a valid member of Model
22:59:34 - Script "Workspace.Spawn House.Spawn?.Head.Script", Line 6
22:59:34 - stack end
22:59:34 - Disconnected event because of exception

Is player suppose to be the Player from 'Players' ?
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
23 Jul 2012 10:02 PM
In that script's case, erase the .Character.
Report Abuse
Monkey1234567890123 is not online. Monkey1234567890123
Joined: 24 Oct 2009
Total Posts: 327
23 Jul 2012 10:08 PM
Removing the '.Character' gave me this output:

23:06:34 - Unable to cast Instance to Vector3
23:06:34 - Script "Workspace.Spawn House.Spawn?.Head.Script", Line 6
23:06:34 - stack end
23:06:34 - Disconnected event because of exception
Report Abuse
Monkey1234567890123 is not online. Monkey1234567890123
Joined: 24 Oct 2009
Total Posts: 327
23 Jul 2012 10:17 PM
doesnt there need to be three(X,Y,Z) things in the :MoveTo()
Report Abuse
1518NICENICKEY is not online. 1518NICENICKEY
Joined: 29 Apr 2009
Total Posts: 1136
23 Jul 2012 10:41 PM
Player.Character:MoveTo(Model:GetChildren()[math.random(#Model:GetChildren())])

Ugg dang it, I think my brain just rotted trying to convert this to something else.
Umm.

Player.Character:MoveTo(Model[math.random(#Model:GetChildren())].Position)

Idk, my brain just farted.
Report Abuse
Monkey1234567890123 is not online. Monkey1234567890123
Joined: 24 Oct 2009
Total Posts: 327
23 Jul 2012 10:49 PM
In this i can't use '.Character' so i changed it to this:


Model = game.Workspace.SpawnBricks

function touched(hit)
local Player = hit.Parent
if Player ~= nil then
Player:MoveTo(Model[math.random(#Model:GetChildren())].Position)
end
end

script.Parent.Touched:connect(touched)


Output: 23:47:11 - 6 is not a valid member of Model
23:47:11 - Script "Workspace.Spawn House.Spawn?.Head.Script", Line 6
23:47:11 - stack end
23:47:11 - Disconnected event because of exception
Report Abuse
koen500 is not online. koen500
Joined: 23 Feb 2011
Total Posts: 2277
23 Jul 2012 10:55 PM
I will usethistoo.
Report Abuse
epicfail22 is not online. epicfail22
Joined: 25 Sep 2009
Total Posts: 3739
24 Jul 2012 12:15 PM
It's not that complicated...

Model = game.Workspace.SpawnBricks
enabled = true
script.Parent.Touched:connect(function(hit)
local player = Game.Players:GetPlayerFromCharacter(hit.Parent)
if player and enabled then
Player.Character:MoveTo(Model:GetChildren()[math.random(1,#Model:GetChildren())].Position + Vector3.new(0,6,0))
end
end)
Report Abuse
Monkey1234567890123 is not online. Monkey1234567890123
Joined: 24 Oct 2009
Total Posts: 327
24 Jul 2012 01:45 PM
thanks man it works! but on line 6 you capitolized the 'p' in player... lol
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