|
| 14 Jul 2016 06:38 PM |
For whatever reason, I can run this in studio and the script will work perfectly fine but If I play the game normally it won't work.. It basically makes a button move to the middle of the screen, then when the player presses it, the musics volume goes down and the button flys back up along with the background. Here's the script (it's a localscript if that helps):
-------------------------------------------------------------------------------------
Assets = {281352478, 134012322}
for _, asset in ipairs(Assets) do game:GetService("ContentProvider"):Preload("http://www.roblox.com/asset/?id=" .. asset) end
_G.firstperson = false
local button = script.Parent
local sound = button.Sound local sound2 = button.Sound2
sound.Volume = 1 sound2.Volume = 0.6
sound2:Play()
function volumeDown(sound) while sound.Volume > 0 do sound.Volume = sound.Volume - 0.1 wait(0.4) end end
button.Visible = false button.Text = ("Start Game") button.Position = UDim2.new(0.38, 0, -1, 0)
wait(3)
button.Visible = true button:TweenPosition(UDim2.new(0.37, 0, 0.6, 0), "Out", "Quad", 1)
local background = button.Parent
function startGame() _G.firstperson = true button:TweenPosition(UDim2.new(0.37, 0, -1, 0)) sound:Play() wait(1) button.Visible = false --background.Visible = false background:TweenPosition(UDim2.new(0, 0, -3, 0), "Out", 3) print("starting") sound:Play() volumeDown(sound2) end
button.MouseButton1Click:connect(startGame)
--------------------------------------------------------------------------------------
If someone could explain to me why this isn't working or has a solution, please tell me, thank you. |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 14 Jul 2016 06:39 PM |
| I'm pretty sure it is because localscripts cannot access global variables. I could be wrong since I don't use global variables since they are pretty inefficient. |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 06:42 PM |
| The global variable that I'm using doesn't need to be accesed by any scripts right now, so that can't be the issue. |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 06:43 PM |
| If it helps, you can try my game and see for yourself.. The button doesn't respond at all, nor does it make a transition. |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 14 Jul 2016 06:44 PM |
are there any errors? check local console and game console |
|
|
| Report Abuse |
|
|
Fangous
|
  |
| Joined: 03 Jul 2010 |
| Total Posts: 4448 |
|
|
| 14 Jul 2016 06:45 PM |
local sound = button.Sound local sound2 = button.Sound2
error is here. check where sound2 is and make sure you spell it right |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 06:49 PM |
I checked and it's spelled corectly, also there were no errors showing up in the console either!
If it helps, this script is parented by several frames in apart of a screengui. The screengui is parented by StarterGui |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 07:09 PM |
wait, you might be right.. I opened console in normal roblox and got this error.
Sound2 is not a valid member of TextButton
so how would I fix that? |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2016 07:15 PM |
| Okay nevermind I fixed it :) |
|
|
| Report Abuse |
|
|