|
| 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 |
|
|
|
| 24 May 2015 03:14 PM |
http://www.roblox.com/Forum/ShowPost.aspx?PostID=162847468
any idea? ._. |
|
|
| Report Abuse |
|
|
| |
|
| |
|
| |
|
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 |
|
|
| |
|
|
| 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 |
|
|
|
| 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 |
|
|
| |
|