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: MouseEnter and MouseLeave

Previous Thread :: Next Thread 
AnorakHalliday is not online. AnorakHalliday
Joined: 11 Jul 2013
Total Posts: 328
24 May 2015 03:11 PM
function MouseEffect(Object)
Object.MouseEnter:connect(function()
Object.BackgroundColor3 = Color3.new(68/255,137/255,205/255)
Object.BorderColor3 = Color3.new(205/255,205/255,205/255)
if Object.Position.X.Scale > 0 then
return
else
Object:TweenPosition(UDim2.new(0.2,0,Object.Position.Y.Scale,0),"Out","Quint",0.5)
end
end)
Object.MouseLeave:connect(function()
Object.BackgroundColor3 = Color3.new(85/255,170/255,255/255)
Object.BorderColor3 = Color3.new(1,1,1)
if Object.Position.X.Scale < 0.2 then
return
else
Object:TweenPosition(UDim2.new(0,0,Object.Position.Y.Scale,0),"Out","Quint",0.5)
end
end)
end

This is supposed to be a simple effect that tweens a button to the right a little bit if the mouse is over it and it tweens it back when its not over it. It works but then when I move the mouse out it does not tween back and I have to do it quite a few times for it to work.
Report Abuse
joshua4560 is not online. joshua4560
Joined: 28 May 2012
Total Posts: 36
24 May 2015 03:14 PM
http://www.roblox.com/Forum/ShowPost.aspx?PostID=162847468

any idea? ._.
Report Abuse
AnorakHalliday is not online. AnorakHalliday
Joined: 11 Jul 2013
Total Posts: 328
24 May 2015 03:44 PM
bump
Report Abuse
AnorakHalliday is not online. AnorakHalliday
Joined: 11 Jul 2013
Total Posts: 328
24 May 2015 05:39 PM
2
Report Abuse
AnorakHalliday is not online. AnorakHalliday
Joined: 11 Jul 2013
Total Posts: 328
24 May 2015 11:02 PM
bump3
Report Abuse
mycheeze is not online. mycheeze
Joined: 27 Jun 2011
Total Posts: 6748
24 May 2015 11:29 PM
You can make it so when the userinputservice detects your mouse moving, it will check the mouse position and compare it to each object you can hover over.

Then firing the function if the mouse position is within the object's size coordinates.
Report Abuse
AnorakHalliday is not online. AnorakHalliday
Joined: 11 Jul 2013
Total Posts: 328
25 May 2015 12:58 PM
what
Report Abuse
Sinfesizer is not online. Sinfesizer
Joined: 18 Apr 2015
Total Posts: 46
25 May 2015 01:07 PM
This is a basic MouseEnter script.

--[[ Hierarchy:

ScreenGui
Frame
LocalScript [ This script ]

--]]

local UserInputService = game:GetService("UserInputService")
local Gui = script.Parent
local Frame = Gui:WaitForChild("Frame")

function MouseEnter(X, Y, Object)
local SX, SY = Object.AbsoluteSize.X, Object.AbsoluteSize.Y
local PX, PY = Object.AbsolutePosition.X, Object.AbsolutePosition.Y
if(X > PX and X < PX + SX and Y > PY and Y < PY + SY)then
return true
end
return false
end

UserInputService.InputChanged:connect(function(Input)
if(Input.UserInputType == Enum.UserInputType.MouseMovement)then
if(MouseEnter(Input.Position.X, Input.Position.Y, Frame))then
-- Code
end
end
end)
Report Abuse
AnorakHalliday is not online. AnorakHalliday
Joined: 11 Jul 2013
Total Posts: 328
25 May 2015 01:15 PM
I get what you guys are saying. But my problem isn't the MouseEnter and MouseLeave. It's the tweening part.

I put my mouse over it, the button tweens the way it should. If I move my mouse out of there before the tween is complete, it will not tween back to it's original position like it should.
Report Abuse
AnorakHalliday is not online. AnorakHalliday
Joined: 11 Jul 2013
Total Posts: 328
25 May 2015 01:18 PM
Nevermind. Got it.
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