PureVoid
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 2624 |
|
|
| 19 Jan 2014 06:49 PM |
This script is supposed to randomly teleport you to a certain part of the game.
It teleports fine, but the only problem is that it you get teleported to the same location every time.
a = math.random(-50,-40) c = math.random(-61,-50)
script.Parent.MouseButton1Down:connect(function() player = script.Parent.Parent.Parent.Parent.Parent player.Character:MoveTo(Vector3.new(a,38.6,c)) game.ServerStorage.LinkedSword:Clone().Parent = player.Backpack end)
Give me a challenge. |
|
|
| Report Abuse |
|
|
PureVoid
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 2624 |
|
| |
|
Oddie9900
|
  |
| Joined: 21 Jul 2011 |
| Total Posts: 108 |
|
| |
|
PureVoid
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 2624 |
|
|
| 19 Jan 2014 07:06 PM |
help please
Give me a challenge. |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2014 07:15 PM |
The problem with your math.random is that the variable assigned to the random is being made before the teleport button.
aka you make your random number ONCE, so that's why it's the same thing all the time.
To fix it, all you have to do is move the variable defining inside the function, like this:
script.Parent.MouseButton1Down:connect(function()
a = math.random(-50,-40) c = math.random(-61,-50)
player = script.Parent.Parent.Parent.Parent.Parent player.Character:MoveTo(Vector3.new(a,38.6,c)) game.ServerStorage.LinkedSword:Clone().Parent = player.Backpack end)
All you really needed to do is make the math.random assigned to a variable each time something happens, so it randomly generates the number each time.
math.random is like a one-time thing; it only makes a random number once. That's why you have to put the math.random inside the loop/function.
Hope this helped! |
|
|
| Report Abuse |
|
|
PureVoid
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 2624 |
|
|
| 19 Jan 2014 07:19 PM |
Trying it now.
Give me a challenge. |
|
|
| Report Abuse |
|
|
PureVoid
|
  |
| Joined: 25 Dec 2011 |
| Total Posts: 2624 |
|
|
| 19 Jan 2014 07:21 PM |
Seems to work... thanks!
Give me a challenge. |
|
|
| Report Abuse |
|
|
|
| 19 Jan 2014 07:22 PM |
| You're welcome, and good luck with the rest of whatever you're doing! |
|
|
| Report Abuse |
|
|