Pexur
|
  |
| Joined: 23 Jun 2008 |
| Total Posts: 12779 |
|
|
| 03 Jan 2016 01:42 PM |
can you not use the click function in this situation?
local Player = game.Players.LocalPlayer local mouse = Player:GetMouse()
while wait() do if mouse.Target ~=nil and mouse.Target.Name == 'HoverBrick' then script.Parent.Visible = true script.Parent.Position = UDim2.new(0, ((mouse.X)-90), 0, ((mouse.Y)-20)) else script.Parent.Visible = false end end
function Click(mouse) if script.Parent.Visible = true then print("CLICKED!") wait(1) end
script.Parent.MouseButton1Down:connect(Click)
|
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 01:43 PM |
| Since your loop keeps repeating over and over again the script never gets to the part where it connects mouse clicking to the Click function. |
|
|
| Report Abuse |
|
|
Pexur
|
  |
| Joined: 23 Jun 2008 |
| Total Posts: 12779 |
|
|
| 03 Jan 2016 01:44 PM |
oh i thought the while true do was a separate function
thanks man
|
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 01:46 PM |
function Click(mouse) if script.Parent.Visible = true then print("CLICKED!") wait(1) end missing end |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 01:47 PM |
Also use the spawn function.
spawn(function() while wait() do --while code here end end) |
|
|
| Report Abuse |
|
|
Pexur
|
  |
| Joined: 23 Jun 2008 |
| Total Posts: 12779 |
|
|
| 03 Jan 2016 01:53 PM |
still not working fml
the hover part is working perfectly but that clicking function never works and there's no errors
i tried your code but it's still broken
is it just not possible?
|
|
|
| Report Abuse |
|
|
Pexur
|
  |
| Joined: 23 Jun 2008 |
| Total Posts: 12779 |
|
|
| 03 Jan 2016 01:53 PM |
also what does the spawn function do
|
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 01:56 PM |
| The spawn function would keep whatever's inside from delaying following code. Basically splits off two separate tracks of delay. I use it if I have multiple while loops or like you have. |
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 02:00 PM |
local Player = game.Players.LocalPlayer local mouse = Player:GetMouse()
spawn(function() while wait() do if mouse.Target ~=nil and mouse.Target.Name == 'HoverBrick' then script.Parent.Visible = true script.Parent.Position = UDim2.new(0, ((mouse.X)-90), 0, ((mouse.Y)-20)) else script.Parent.Visible = false end end end)
function Click(mouse) if mouse.Target ~= script.Parent.Parent then -- Script.Parent.Parent should be in either the character, or the starterpack! LocalScripts don't function outside of the player or it's character. return -- Stops the script since they didn't click on the part that has the clickdetector end if script.Parent.Visible = true then print("CLICKED!") wait(1) end end
mouse.Button1Down:connect(Click) -- Old click function was deprecated. |
|
|
| Report Abuse |
|
|
Pexur
|
  |
| Joined: 23 Jun 2008 |
| Total Posts: 12779 |
|
|
| 03 Jan 2016 02:09 PM |
ohhh you need a click detector in the part?
|
|
|
| Report Abuse |
|
|
|
| 03 Jan 2016 02:13 PM |
| The clickdetector has the function but it is deprecated. Use my code and read the comments. (deprecated means outdated and no longer used.) |
|
|
| Report Abuse |
|
|
Pexur
|
  |
| Joined: 23 Jun 2008 |
| Total Posts: 12779 |
|
|
| 03 Jan 2016 02:15 PM |
thanks dude i finally got it to work aha im new at this so a lot of this doesnt make sense especially local scripts
|
|
|
| Report Abuse |
|
|
Pexur
|
  |
| Joined: 23 Jun 2008 |
| Total Posts: 12779 |
|
|
| 03 Jan 2016 02:18 PM |
Players.Player.PlayerGui.Hover.Frame.LocalScript:17: attempt to index local 'mouse' (a nil value)
|
|
|
| Report Abuse |
|
|
| |
|
| |
|