Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 03 Mar 2017 04:08 PM |
yeah i know i posted something similar last night but I am really lost here. I don't THINK I'm doing anything wrong but I guess I must be. I am currently trying to make a random GUI pop up on a random part of the screen, here's my script:
game.ReplicatedStorage.ProcessPurchase.OnClientEvent:connect(function(quantity) for i = 1, quantity do wait() local x = game.ReplicatedStorage.casheffect:Clone() x.Parent = script.Parent.UI x.Position = UDim2.new(math.random(1,1000) / 1000, 0 , math.random(1,1000) / 1000, 0) end end)
Only focus on the math.random() part you dont need to know whats firing it or anything because that all works. Each GUI that it clones goes to the exact same spot on the screen, which I'm pretty sure it shouldn't do.
Also, there is another instance of math.random() not working here (but I am pretty sure I'm doing something wrong in this one):
https://www.youtube.com/watch?v=UxOR1rL_TIY
Anyways, thanks for any feedback! |
|
|
| Report Abuse |
|
|
devHoodie
|
  |
| Joined: 04 Nov 2008 |
| Total Posts: 30332 |
|
|
| 03 Mar 2017 04:09 PM |
maybe type this at the beginning of the event:
math.randomseed(tick())
-- Former AKA : luis15232 |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 03 Mar 2017 04:10 PM |
| I have that at the top, forgot to mention that. |
|
|
| Report Abuse |
|
|
|
| 03 Mar 2017 04:11 PM |
P.G.O
Thank You
Signed,EvilDonutNoob |
|
|
| Report Abuse |
|
|
devHoodie
|
  |
| Joined: 04 Nov 2008 |
| Total Posts: 30332 |
|
|
| 03 Mar 2017 04:11 PM |
Put it in the event.
If you're testing in studio tick will always be the same.
-- Former AKA : luis15232 |
|
|
| Report Abuse |
|
|
devHoodie
|
  |
| Joined: 04 Nov 2008 |
| Total Posts: 30332 |
|
|
| 03 Mar 2017 04:12 PM |
(as far as i know)
-- Former AKA : luis15232 |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 03 Mar 2017 04:14 PM |
| that doesn't work either I've tried that. |
|
|
| Report Abuse |
|
|
devHoodie
|
  |
| Joined: 04 Nov 2008 |
| Total Posts: 30332 |
|
|
| 03 Mar 2017 04:17 PM |
maybe you're changing the position of the wrong thing
-- Former AKA : luis15232 |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
| |
|
devHoodie
|
  |
| Joined: 04 Nov 2008 |
| Total Posts: 30332 |
|
|
| 03 Mar 2017 04:19 PM |
where is the GUI appearing on the screen?
-- Former AKA : luis15232 |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 03 Mar 2017 04:21 PM |
I'm not crazy or a bad scripter by any means.
The directories are all fine how they should be and eveything is working how it should EXCEPT the random positions. This also is not the first time math.random is not random in this game. I am getting really annoyed because math.random isn't something that I should have to worry about. It's really slowing my development process, because these problems haven't happened before to me ever. |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
| |
|
hasang1
|
  |
| Joined: 09 Nov 2012 |
| Total Posts: 903 |
|
|
| 03 Mar 2017 04:39 PM |
math.random can be confusing at times, try to do a different math.randomseed(), I'd personally suggest a few random numbers multiplying/dividing/adding/etc to time functions Ex. math.randomseed(os.time()*42+tick()/13.37)
ROBLOX tagged my signature about how to avoid getting your posts tagged. Handy to know. |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 03 Mar 2017 04:42 PM |
@hasang
sorry but that didnt work either :( |
|
|
| Report Abuse |
|
|
hasang1
|
  |
| Joined: 09 Nov 2012 |
| Total Posts: 903 |
|
|
| 03 Mar 2017 04:45 PM |
Something is VERY wrong then. And I can't tell what.
ROBLOX tagged my signature about how to avoid getting your posts tagged. Handy to know. |
|
|
| Report Abuse |
|
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Mar 2017 04:47 PM |
--local script
math.randomseed(tick()) local process = game.ReplicatedStorage:WaitForChild('ProcessPurchase') local effect = game.ReplicatedStorage:WaitForChid('CashEffect') local gui = script.Parent local ui = gui:WaitForChild('UI')
process.OnClientEvent:connect(function(amount) for i = 1,amount do local effect = effect:Clone() effect.Parent = ui effect.Position = UDim2.new(math.random(1,100)/100,0,math.random(1,100)/100,0) wait() end end)
|
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
| |
|
TimeTicks
|
  |
| Joined: 27 Apr 2011 |
| Total Posts: 27115 |
|
|
| 03 Mar 2017 04:50 PM |
print(gui.Position)
probably because the values are so tiny you barely see a change
|
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 03 Mar 2017 04:53 PM |
| they are relatively large and they all spawn on the same exact position |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
| |
|
|
| 03 Mar 2017 05:13 PM |
| The first argument which is the number you are starting at is actually optional and not needed if you are starting at 0 or 1. |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 03 Mar 2017 05:14 PM |
| ^ but that doesnt make a difference for what im doing |
|
|
| Report Abuse |
|
|
devHoodie
|
  |
| Joined: 04 Nov 2008 |
| Total Posts: 30332 |
|
|
| 03 Mar 2017 05:50 PM |
i asked where the gui appears on screen so i can find a correlation with the random and the position
-- Former AKA : luis15232 |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
| |
|
devHoodie
|
  |
| Joined: 04 Nov 2008 |
| Total Posts: 30332 |
|
|
| 03 Mar 2017 06:01 PM |
the position of the GUI
-- Former AKA : luis15232 |
|
|
| Report Abuse |
|
|