|
| 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 |
|
|
| |
|
|
| 14 Jul 2014 07:22 AM |
| The wizards must be resetting, |
|
|
| Report Abuse |
|
|
| |
|
|
| 14 Jul 2014 07:35 AM |
| http://blog.roblox.com/2012/02/an-optimization-for-lua-scripts-2/ |
|
|
| Report Abuse |
|
|
|
| 14 Jul 2014 07:45 AM |
| Well that was super helpful, |
|
|
| Report Abuse |
|
|
|
| 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 |
|
|
|
| 14 Jul 2014 09:02 AM |
| I read it, nothing I needed. |
|
|
| Report Abuse |
|
|
|
| 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
|
  |
| 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 |
|
|
|
| 16 Jul 2014 06:14 AM |
| u should use mouse.Move not a loop |
|
|
| Report Abuse |
|
|
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 |
|
|