Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

MouseEnter Refireing when clicked???

Asked by
LostPast 253 Moderation Voter
8 years ago

If you click the Frame while your mouse is over it, it will fire MouseEnter again.

function tweentrans()
end

script.Parent.MouseEnter:connect(function()
    print("1")
    inFrame = true
    tweentrans()
end)

script.Parent.MouseLeave:connect(function()
    print("2")
    inFrame = false
end)
0
Ah, I didn't know this. I can see how that would be annoying. This must be a bug. I don't see an easy solution. User#11440 120 — 8y

1 answer

Log in to vote
3
Answered by 8 years ago

the reason why this happened is the same reason why when you touch a brick on a touch event with a print('random text') it will print it multiple times because your constantly on it. however if we add some debouncers and if statments (which will stop the code from running more than you need it to) then youll be able to control the monstrosity.

local inFrame = true -- this is out debouncer
function tweentransformation()
end

script.Parent.MouseEnter:connect(function()
if inFrame then -- checks to see if inFrame == true
inFrame = false --[[this is so it doesnt reprint(1) until we set it to true--]]
    print("1")
    tweentransformation()
-- [[places the function in here so the mouseleave function can only fire when it has been inside the             frame --]]
script.Parent.MouseLeave:connect(function()
if not inFrame then --[[checks if inFrame == false. so adding wait()'s in perfectly fine.--]]
    print("2")
    inFrame = true --[[put inFrames to true so MouseEnter() can play again--]]
end -- end if statment
end) -- end function
end -- to end the if statement
end) -- end function





0
You did a really great job at explaining this. However, this isn't a very good solution, however it may be the only one. So I'll give it to you. User#11440 120 — 8y
Ad

Answer this question