|
| 08 Jul 2017 07:17 AM |
So in my game, there's an area called the maze. There are walls all over the place, and a script decides randomly with math.random tick if they are there or not. The current script for the variable "visible" is; visible = math.random(2)
If it's equal to one, then it's visible. If it's equal to 2, it's invisible. I duplicated the wall with the script to make every single wall random. However, it causes all walls to either be there or not there (All walls visible or all walls not visible). Is there any way to make the variable "visible" local to it's own script? |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2017 07:26 AM |
Can you post the whole script?
And why not just do script.Parent.Transparency = math.random(0, 1)
I tried using visible = math.random(2) its working prefectly |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2017 07:30 AM |
| It's also if you can collide with it. Here's the whole script: while true do math.randomseed(tick()) for _ = 1, 2 do visible = math.random(2) if visible == # #### ########################## = 0 script.Parent.CanCollide = true elseif visible == # #### ########################## = 1 script.Parent.CanCollide = false end wait(1200) end end |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2017 07:37 AM |
| It won't let me post the whole thing, it keeps censoring and glitching. Well, it's also supposed to be if the player can collide with it or not |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2017 07:45 AM |
| What I'm looking for is how to make variables local to their own script. |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2017 07:51 AM |
Put all your maze part in one model, and put this script inside the model
math.randomseed(tick())
while true do for i, v in pairs(script.Parent:GetChildren()) do
if v:IsA("BasePart") then random = math.random(0,1) v.CanCollide = (random < 0.5) v.Transparency = random end
end wait(1) end
--Change the value inside wait() to change how fast they changed
--Also be sure to delete your old script |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2017 07:56 AM |
I can't really understand your script and i don't know much about randomseed
but i guess its either your put wait(1200) in the wrong place that it only changed 1 brick and waited 1200 seconds
or maybe its because you put randomseed inside the loop, that it asked for different seed everytime. |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2017 08:03 AM |
The variables are local to their own script, it's math.random() that isn't working properly. It is giving you a random number, but it is giving the same random number everywhere.
Try adding:
math.randomseede(tick())
to the first line of th script. |
|
|
| Report Abuse |
|
|
| |
|
|
| 08 Jul 2017 08:41 AM |
| Sorry Cowsoncows, unfortunately it's still not working. |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2017 08:42 AM |
| Each wall has it's own script. |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2017 08:44 AM |
| Actually, maybe math.randomseed(tick()) is the problem. tick() gives unix time (time elapsed since january 1st 1970) so if every script calls it at the same time, every script is getting the same seed thus has the same output for math.random. |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2017 09:38 AM |
@MonoBlockZ
That actually worked! Would you mind teaching me how it works? |
|
|
| Report Abuse |
|
|
|
| 08 Jul 2017 09:41 AM |
| Thanks for the advice from both of you! Now the maze can't be memorized by players! I really appreciate it! |
|
|
| Report Abuse |
|
|
braylee8
|
  |
| Joined: 09 Jun 2015 |
| Total Posts: 1 |
|
|
| 18 Jul 2017 11:53 AM |
| Hey, my name is Braylee was wondering, since you work for assassin(Like I saw) I want to have earth elemental. Now I know you will decline at ##### BUT! I got scammed my earth elemental was scammed. I don't know by who but all I know is.. that I miss it. And I need you're help, maybe you could just give me a hand and just Do a little of skills at hacking maybe.. And get my knife back? Please, that would mean the world to me! |
|
|
| Report Abuse |
|
|