|
| 27 Sep 2017 02:51 PM |
im just testing some math random stuff what did i did wrong if the scripts is wrong wrong dont laugh im just doing experiments script - script.Parent.Touched:connect(function() while true do printtochoosefrom = math random(1.3) if printtochoosefrom == 1 then print("what") end if printtochoosefrom == 2 then print("who") end if printtochoosefrom == 3 then print("when") end end) |
|
|
| Report Abuse |
|
|
iiNemo
|
  |
| Joined: 22 Jul 2013 |
| Total Posts: 2380 |
|
|
| 27 Sep 2017 02:53 PM |
a lot is wrong script.Parent.Touched:Connect(function() while true do local printtochoosefrom = math random(1, 3) if printtochoosefrom == 1 then print("what") elseif printtochoosefrom == 2 then print("who") elseif printtochoosefrom == 3 then print("when") end end) |
|
|
| Report Abuse |
|
|
iiNemo
|
  |
| Joined: 22 Jul 2013 |
| Total Posts: 2380 |
|
|
| 27 Sep 2017 02:55 PM |
script.Parent.Touched:Connect(function() local printtochoosefrom = math random(1, 3) if printtochoosefrom == 1 then print("what") elseif printtochoosefrom == 2 then print("who") elseif printtochoosefrom == 3 then print("when") end end)
You also made absolutely 0 sense. |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2017 02:55 PM |
| ow thank you so much for your help sir |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2017 02:57 PM |
dint work script.Parent.Touched:Connect(function() while true do local printtochoosefrom = math random(1, 3) if printtochoosefrom == 1 then print("what") elseif printtochoosefrom == 2 then print("who") elseif printtochoosefrom == 3 then print("when") end end)
it said unexpectted sysmbol at ) what is this problem |
|
|
| Report Abuse |
|
|
iiNemo
|
  |
| Joined: 22 Jul 2013 |
| Total Posts: 2380 |
|
|
| 27 Sep 2017 02:58 PM |
| use the second one I posted.. |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2017 02:58 PM |
| now it says Workspace.Part.Script:2: attempt to call global 'random' (a nil value) |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2017 03:46 PM |
local content = { [1] = "what"; [2] = "who"; --this is a table; it stores strings, numbers, and bools, and in some cases other stuff like instances [3] = "when"; };
script.Parent.Touched:Connect(function() --anonymous function local printtochoosefrom = math.random(1,3) print(content[printtochoosefrom]) --since 'printtochoosefrom' is a number, we can apply it in the array of stuff inside the table end)
#code error("you're*") |
|
|
| Report Abuse |
|
|
|
| 27 Sep 2017 03:59 PM |
The reason why you received that error is because you both forgot to use math.random
|
|
|
| Report Abuse |
|
|
| |
|