#Mouse Events Don't Connect [Please Help]

1 messages · Page 1 of 1 (latest)

modern dune
#

So I'm trying to integrate an old TextLabel Hyperlink compatibility script by rogeriodec_games (original below), but I've run into a bit of an issue in that even though the portion of the script that should be assigning mouse event connections (MouseEnter, MouseLeave, MouseButton1Down, etc) runs fine (all debug prints output without issue) the actual element on the UI does not respond to mouse events at all. The element itself and all its parents are .Active = true it is the highest Z-Index element in the entire UI, and it appears perfectly fine on said UI it just doesn't respond to the mouse, and I am utterly lost on why.

Original Dev Forum: https://devforum.roblox.com/t/creating-hyperlinks-for-internal-documentation/1972977

#

Output in console since I forgot to add that:

#

This portion here is the part that isn't working as intended:

if Type == 'TextButton' then
    print("This prints fine.")
    Text.Text = '<u>' .. Text.Text .. '</u>'
    if LinkColor then Text.TextColor3 = LinkColor end
    local TextColor3 = Text.TextColor3

    Text.MouseEnter:Connect(function() -- Doesn't actually seem to function.
        print("Entered")
        if HoverColor then Text.TextColor3 = HoverColor end
    end)

    Text.MouseLeave:Connect(function() -- Doesn't actually seem to function.
        print("Left")
        Text.TextColor3 = TextColor3
    end)

    Text.MouseButton1Down:Connect(function() -- Doesn't actually seem to function.
        print("Clicked")
        print(Object.Href)
    end)

    print("This also prints fine.")
end
#

I think it might have something to do with the button hitbox as other events do behave correctly.

if Type == 'TextButton' then
    print("This prints fine.")
    Text.Destroying:Connect(function()
        print("AAAAAAA") -- This does print, might be something to do with the mouse hitbox?
    end)
    
    print("This also prints fine.")
    Text:Destroy() -- Correctly triggers Destroying Event.
end
#

The button does highlight when hovered over, though (using autocolor, not the script). 🤔

hybrid abyss
modern dune
hybrid abyss
#

this script is so fucking ass

#

like how are you supposed to read this

modern dune
#

The start and end prints go to the console, but the connections in between just do not work.

#

It seems to be isolated to mouse related connections for whatever reason.

burnt archBOT
#

studio** You are now Level 11! **studio

hybrid abyss
#
script.Parent.MouseEnter:Connect(function()
    print("works")
end)

pasting ts in a new script also doesnt work.

#

wehn having the other one active aswell

#

I think I know why

#

we are listening to the wrong button

modern dune
#

And printing out the buttons full name indicates it should be the correct one before and after making connections.

#

Lemme grab the test for that again real quick...

hybrid abyss
#

nvm its not that

#

we are listening to the right things🥀🥀

modern dune
#

Test Section

if Type == 'TextButton' then
    print("This prints fine.")
    print(Text:GetFullName())
    Text.Text = '<u>' .. Text.Text .. '</u>'
    if LinkColor then Text.TextColor3 = LinkColor end
    local TextColor3 = Text.TextColor3

    Text.MouseEnter:Connect(function() -- Doesn't actually seem to function.
        print("Entered")
        if HoverColor then Text.TextColor3 = HoverColor end
    end)

    Text.MouseLeave:Connect(function() -- Doesn't actually seem to function.
        print("Left")
        Text.TextColor3 = TextColor3
    end)

    Text.MouseButton1Down:Connect(function() -- Doesn't actually seem to function.
        print("Clicked")
        print(Object.Href)
    end)
    Text.AncestryChanged:Connect(function()
        print("The button changed ancestors.")
    end)
    
    Text.Destroying:Connect(function()
        print("The button was destroyed.")
    end)
    
    print(Text:GetFullName())
    Text.Parent = Text.Parent.Parent -- Trigger AncestryChanged
    Text:Destroy() -- Trigger Destroying and AncestryChanged (AncestoryChanged to nil).
    
    print("This also prints fine.")
end

Test Response:

hybrid abyss
modern dune
#

How'd you do it? :O

hybrid abyss
#

TextLabel:Destroy() -- remove the original TextLabel (with HTML Tags) if you delete the original TextLabel on line 147 it seems to break

modern dune
#

Oh my gosh, thank you so much. This has been driving me mad for hours. XD

hybrid abyss
#

npnp

#

idk why it breaks tho

#

cause these are 2 new buttons which should work individually

#

OMG

#

@modern dune

modern dune
#

Yes?

hybrid abyss
#

IF WE BREAK THE PARENT THE SCRIPT ALSO GETS DELETED🐒

modern dune
#

OH. XD

#

That makes a lot more sense lmao.

hybrid abyss
#

yea

#

maybe dont make the button the parent

#

and then you can also delete it

modern dune
#

Yeah, I did that for basic testing. Really face-palmed that one. X_X

hybrid abyss
modern dune
#

Thank you for figuring it out for my dumb brain.