generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Game Design
Home Search
 

Re: My script works in Studio, but not in normal Roblox

Previous Thread :: Next Thread 
coolsupersonic103 is not online. coolsupersonic103
Joined: 28 Jun 2010
Total Posts: 78
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 is not online. 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
coolsupersonic103 is not online. coolsupersonic103
Joined: 28 Jun 2010
Total Posts: 78
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
coolsupersonic103 is not online. coolsupersonic103
Joined: 28 Jun 2010
Total Posts: 78
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 is not online. 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 is not online. 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
coolsupersonic103 is not online. coolsupersonic103
Joined: 28 Jun 2010
Total Posts: 78
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
coolsupersonic103 is not online. coolsupersonic103
Joined: 28 Jun 2010
Total Posts: 78
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
coolsupersonic103 is not online. coolsupersonic103
Joined: 28 Jun 2010
Total Posts: 78
14 Jul 2016 07:15 PM
Okay nevermind I fixed it :)
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Game Design
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image