I’m creating a title screen and to simplify the server load and better readability, I tried making a button class for each button object. I tried connecting the RBXScriptSignal MouseEnter
but I received a type error. What do I do?
buttonClass is a table, it has no such key.
It is, and I am attempting to make it a class, and make the buttons objects so that I can make one RBXScriptSignal for checking if the MouseEntered once and not make 4 functions for each button.
That was my question in the title.
buttonClass
is a table, it has no such key.
could you please provide the code?
Script analisis seem to not recognize the key
Could you explain to me what you think I’m attempting to do? I can’t tell if you understand what I’m asking.
local titleScreenGui = script.Parent
local titleScreenLogo = titleScreenGui:WaitForChild("Logo")
local titleScreenTriangle = titleScreenGui:WaitForChild("Triangle")
local buttonClass = {}
buttonClass.__index = buttonClass
local titleScreenButtons = {
playButton = titleScreenGui:WaitForChild("PlayButton"),
serversButton = titleScreenGui:WaitForChild("ServersButton"),
creditsButton = titleScreenGui:WaitForChild("CreditsButton"),
donationsButton = titleScreenGui:WaitForChild("DonateButton")
}
buttonClass.MouseEnter:Connect(function()
--blah blah
end)
MouseEnter
is not a key of buttonClass
can’t you just use a frame?
It is indeed intended for such purpose.
Bro is trying to hack matrix istg
Why do you simply not use a TextButton
or ImageButton
? This just seems convoluted. You do not even have an entry titled MouseEnter
in your buttonClass
metatable, unless the screenshot you had provided is not the full script.
Utilizing metatables can be counter-productive towards this, as they can destroy readability and overcomplicate it to hell, making it more difficult to maintain.
Yeah, I asked someone else somewhere else and am instead opting for looping through a table with all of the buttons and using the signal like so. Thank you for the thought-provoking reply.
for i, v in pairs(titleScreenButtons) do
v.MouseEnter:Connect(function()
end)
end
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.