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 » Scripters
Home Search
 

Re: Script works fine in studio not in game

Previous Thread :: Next Thread 
Bit_blox is not online. Bit_blox
Joined: 28 Aug 2016
Total Posts: 974
02 Oct 2016 02:30 PM
###############################################################################################################################################################################################################################################################################################################################################################################################################################################
Report Abuse
Bit_blox is not online. Bit_blox
Joined: 28 Aug 2016
Total Posts: 974
02 Oct 2016 02:31 PM
.-. heres script

repeat wait() until game.Players.LocalPlayer
local f = game.Players.LocalPlayer.PlayerGui.dominusInfo.Frame
function onClick()
if f.Visible == true then
end
if f.Visible == false then
f.Visible = true
end
end
script.Parent.ClickDetector.MouseClick:connect(onClick)

and game

https://www.roblox.com/games/490932829/My-hangout


Report Abuse
DevDays is not online. DevDays
Joined: 16 Dec 2015
Total Posts: 112
02 Oct 2016 02:37 PM
On Roblox studio, all assets loads instantly, meanwhile in-game it takes a small fraction of a second to load but it's enough to make your script break.

For example:
Let's say i execute a code in a LocalScript, and under the LocalScript i have a IntValue.

--Code
print(script.IntValue.Value)
--/Code

What will happen:
Roblox Studio: It prints out the value, no errors given.
Game: It'll give you an error saying that the IntValue is missing, that's beacause the object loaded after you executed the script.

How to avoid that:
Give time for the object to load(just add a wait() before the script but in certain cases it's not enough.

The best solution is to use WaitForChild().



kappa
Report Abuse
TimeTicks is not online. TimeTicks
Joined: 27 Apr 2011
Total Posts: 27115
02 Oct 2016 02:38 PM
--server script

script.Parent.ClickDetector.MouseClick:connect(function(player)
local info = player.PlayerGui:WaitForChild('DominusInfo')
local frame = info:WaitForChild('Frame')
frame.Visible = not frame.Visible
end)


Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • 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