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 » Scripting Helpers
Home Search
 

Re: Script Optimization

Previous Thread :: Next Thread 
harvest109 is not online. harvest109
Joined: 19 Jun 2011
Total Posts: 869
14 Jul 2014 07:00 AM
wait()
local Player = Game.Players.LocalPlayer
local mouse = Player:GetMouse()
local MyBrick = game.Workspace.brik
local gui = MyBrick.test.f.t
wait()
while true do
wait(0.1)
if mouse.Target == MyBrick then
gui.Text = "Mouse is over"
print'Mouse is Over'
else
gui.Text = "Mouse is not over"
print'Mouse is not over'
end
end


Could I make this better in any way? It fully functions I just think it could be my optimized, but i'm not advanced enough to figure out how. Oh please great wizards of the SH relm help me in my quest.
Report Abuse
harvest109 is not online. harvest109
Joined: 19 Jun 2011
Total Posts: 869
14 Jul 2014 07:09 AM
MouseClick(bump)
Report Abuse
harvest109 is not online. harvest109
Joined: 19 Jun 2011
Total Posts: 869
14 Jul 2014 07:22 AM
The wizards must be resetting,
Report Abuse
harvest109 is not online. harvest109
Joined: 19 Jun 2011
Total Posts: 869
14 Jul 2014 07:26 AM
Bam1
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
14 Jul 2014 07:35 AM
http://blog.roblox.com/2012/02/an-optimization-for-lua-scripts-2/
Report Abuse
harvest109 is not online. harvest109
Joined: 19 Jun 2011
Total Posts: 869
14 Jul 2014 07:45 AM
Well that was super helpful,
Report Abuse
JarodOfOrbiter is not online. JarodOfOrbiter
Joined: 17 Feb 2011
Total Posts: 20029
14 Jul 2014 08:01 AM
Apparently you are not the type that learns through reading like I am.
But if you didn't want optimizing tips, why did you ask?

And actually, if you took the time and read through it, it would be very interesting and profitable. Yes, it was super helpful.

Someone is just super impatient though.
Report Abuse
harvest109 is not online. harvest109
Joined: 19 Jun 2011
Total Posts: 869
14 Jul 2014 09:02 AM
I read it, nothing I needed.
Report Abuse
thejonathann is not online. thejonathann
Joined: 14 Dec 2010
Total Posts: 76
16 Jul 2014 03:04 AM
Yes this can be slightly optimized...

local mouse = Game.Players.LocalPlayer:GetMouse()
local MyBrick = Workspace.brik
local gui = MyBrick.test.f.t
wait()
while true do
wait(0.1)
if mouse.Target == MyBrick then
gui.Text = "Mouse is over"
print'Mouse is Over'
else
gui.Text = "Mouse is not over"
print'Mouse is not over'
end
end

When you did Game.Workspace you had one extra index and when you had Player = Game.Players.LocalPlayer you caused an extra assignment and index

Don't make a variable for something you're only going to use to make another variable one time.
Report Abuse
nomer888 is not online. nomer888
Joined: 13 Feb 2010
Total Posts: 551
16 Jul 2014 04:19 AM
local mouse = game.Players.LocalPlayer:GetMouse()
local MyBrick = Workspace.brik
local gui = MyBrick.test.f.t

while wait(.1) do
local result = (mouse.Target == MyBrick and 'over' or 'not over')
gui.Text = ("Mouse is "..result)
print("Mouse is"..result) --or just print(gui.Text)
end

Not tested, should work. If you want to get rid of printing at any time, which there isn't much of a point in having it since you said it fully functions, remove the print line and put the declaration of "result" in place of "result" in the gui.Text declaration:

gui.Text = ("Mouse is "..(mouse.Target == MyBrick and 'over' or 'not over'))
Report Abuse
brinkokevin is not online. brinkokevin
Joined: 25 Jul 2012
Total Posts: 1673
16 Jul 2014 06:14 AM
u should use mouse.Move not a loop
Report Abuse
DrFeynman is not online. DrFeynman
Joined: 07 Aug 2013
Total Posts: 178
16 Jul 2014 07:29 AM
I agree with above, you shouldn't use loops unless you absolute have to it eats up a lot or resource time, I have a Extremely optimal script you can use for this.
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripting Helpers
   
 
   
  • 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