Alexware
|
  |
| Joined: 07 May 2010 |
| Total Posts: 661 |
|
|
| 12 Jun 2015 04:09 PM |
I'm trying to get a child frame to follow the user's mouse when they enter a parent frame
Here is the script I have, I tried my best repeat wait() until game.Players.LocalPlayer:GetMouse() ~= nil Mouse = game.Players.LocalPlayer:GetMouse() function onEnter() if game.Players.LocalPlayer.InteractionInUse.Value == false then script.Parent.CouchFunctionFrame.Visible = true game.Players.LocalPlayer.InteractionInUse.Value = true end end
function onMove() if game.Players.LocalPlayer.InteractionInUse == true then script.Parent.CouchFunctionFrame.Position.X.Offset = Vector3.new(Mouse.X) print("Works") script.Parent.CouchFunctionFrame.Position.Y.Offset = Vector3.new(Mouse.Y) end end
function onLeave() if game.Players.LocalPlayer.InteractionInUse.Value == true then script.Parent.CouchFunctionFrame.Visible = false game.Players.LocalPlayer.InteractionInUse.Value = false end end
script.Parent.MouseEnter:connect(onEnter) script.Parent.MouseLeave:connect(onLeave) script.Parent.MouseMoved:connect(onMove)
How can I get it for the child frame(CouchFunctionFrame) to become visible and follow the user's mouse upon entering the parent frame?
Other info: the surfacegui is in the startergui and is adorneed to the item, so yes, localplayer does work... and nothing is showing up in console, so I don't know what I am doing wrong. . .
Alexware |
|
|
| Report Abuse |
|
|
teseting
|
  |
| Joined: 15 Sep 2008 |
| Total Posts: 2535 |
|
|
| 12 Jun 2015 04:39 PM |
repeat wait() until game.Players.LocalPlayer:GetMouse() ~= nil Mouse = game.Players.LocalPlayer:GetMouse()
script.Parent.MouseMoved:connect(function ()
script.Parent.CouchFunctionFrame.Position = UDim2.new(0,Mouse.X,0,Mouse.Y)
end)
function change()
script.Parent.CouchFunctionFrame.Visible = not game.Players.LocalPlayer.InteractionInUse.Value game.Players.LocalPlayer.InteractionInUse.Value = not game.Players.LocalPlayer.InteractionInUse.Value end
script.Parent.MouseEnter:connect(change) script.Parent.MouseLeave:connect(change)
|
|
|
| Report Abuse |
|
|
Alexware
|
  |
| Joined: 07 May 2010 |
| Total Posts: 661 |
|
|
| 12 Jun 2015 04:41 PM |
| Thanks! The only issue now is that it is offset, I'll try to change it with the ,0, in the x and y |
|
|
| Report Abuse |
|
|