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: Scripting Question.

Previous Thread :: Next Thread 
ForeverTaIl is not online. ForeverTaIl
Joined: 10 Dec 2011
Total Posts: 114486
10 May 2015 06:53 PM
I'm trying to make a gui where if the mouse enters the gui, a brick moves forward across the map with the camera following it.

However, I want the brick to stop once the mouse leaves the gui. So far, I've got this:

repeat wait() until game.Workspace.Camera
local target = game.Workspace.CameraStarterPart
local camera = game.Workspace.Camera
camera.CameraSubject = game.Workspace.CameraStarterPart
camera.CameraType = "Scriptable"
local angle = 0


function Mouseenter()
while true do
game.Workspace.CameraStarterPart.CFrame = game.Workspace.CameraStarterPart.CFrame+Vector3.new(1,0,-1)
camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(30.4, angle+150.3, 0)
wait(0.001)
end
end

function Mouseleave()
game.Workspace.CameraStarterPart.CFrame = CFrame.new(game.Workspace.CameraStarterPart.Position)
camera.CoordinateFrame = CFrame.new(target.Position) * CFrame.Angles(30.4, angle+150.3, 0)
wait()
end

script.Parent.MouseEnter:connect(Mouseenter)
script.Parent.MouseLeave:connect(Mouseleave)


I've been stuck on this for a while. Right now, when the mouse enters the GUI, the brick takes off and keeps going, not stopping when it leaves the GUI.


Any help would be great, thanks!
Report Abuse
ForeverTaIl is not online. ForeverTaIl
Joined: 10 Dec 2011
Total Posts: 114486
10 May 2015 06:56 PM
hi
Report Abuse
ForeverTaIl is not online. ForeverTaIl
Joined: 10 Dec 2011
Total Posts: 114486
10 May 2015 06:59 PM
hi[2]
Report Abuse
ForeverTaIl is not online. ForeverTaIl
Joined: 10 Dec 2011
Total Posts: 114486
10 May 2015 07:05 PM
helppp
Report Abuse
ForeverTaIl is not online. ForeverTaIl
Joined: 10 Dec 2011
Total Posts: 114486
10 May 2015 07:18 PM
qq
Report Abuse
kingkendrick141 is not online. kingkendrick141
Joined: 16 Sep 2009
Total Posts: 12172
10 May 2015 07:20 PM
Use body velocities.


Goodness Gracious that Booty is Spacious!
Report Abuse
InnovatedFighting is not online. InnovatedFighting
Joined: 30 Oct 2014
Total Posts: 1040
10 May 2015 07:20 PM
I would think it would be caused by the infinite loop(while true do), perhaps make a local variable "mouseIsOnGUI" or something and say "while mouseIsOnGUI do", then have something to set mouseIsOnGUI to false in the mouseleave method, that would be my best guess but I'm a little new to scripting.

--Gun Fighter Extraordinaire, InnovatedFighting--
--Gun Fighter Extraordinaire, InnovatedFighting--
Report Abuse
ForeverTaIl is not online. ForeverTaIl
Joined: 10 Dec 2011
Total Posts: 114486
10 May 2015 07:22 PM
Body Velocity doesn't run as smooth as CFrame does, especially with the camera.
Report Abuse
ForeverTaIl is not online. ForeverTaIl
Joined: 10 Dec 2011
Total Posts: 114486
10 May 2015 07:24 PM
@inno


The trouble is, what do I make MouseIsOnGUI?

And I still have a loop problem, I would need a break somewhere in here.
Report Abuse
Ice7 is not online. Ice7
Joined: 26 Jun 2007
Total Posts: 1058
11 May 2015 02:07 PM
The MouseEnter event fires every time the Gui contains the mouse's coordinates and by adding a loop inside you are blocking the event from firing again until the loop is finished.

If you insist on using CFrame, then handle the the loop in a separate thread. You can do this using the spawn() function.


local Moving=false
Gui.MouseEnter:connect(function()
Moving=true
spawn(function()

while (Moving) do
P.CFrame = stuff
Camera.CoordinateFrame = stuff
end)

end)

Gui.MouseLeave:connect(function()
Moving=false
Camera.CoordinateFrame = stuff
end)

Rather than
Report Abuse
Ice7 is not online. Ice7
Joined: 26 Jun 2007
Total Posts: 1058
11 May 2015 02:08 PM
Rather than continously updating the camera, you could just alternatively set the Camera Subject unless you want to change the focus over time
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