Hello, I am having an issue with this script. I’m unsure of how I would fix this table as it returns the error “attempt to index nil with MouseEnter.” It is supposed to change a few UI text and colours when the player hovers over the said UI. Any Help is appreciated. I’m relatively new to using tables so I’m not really sure on how some of this stuff works correctly.
I know that i/v is being returned as nil, but i don’t know how i could resolve this correctly.
plr = game.Players.LocalPlayer
char = plr.Character or plr.CharacterAdded:Wait()
class = plr.PlayerScripts:FindFirstChild("Class")
KitRemoteEvent = game.ReplicatedStorage.KitRE
MainGUI = script.Parent
--Flavour Text for exiting button descriptions.
FlavourText = {
"How's your day been?",
"Exclusive Classes are exclusive to specific players.",
"...",
"All classes should be oriented around playstyle, so feel free to take them all out for a test!",
}
-- Classes
Classes = {
None = {BGColor = ColorSequence.new{ColorSequenceKeypoint.new(0, Color3.fromRGB(39,39,39)), ColorSequenceKeypoint.new(1, Color3.new(0,0,0))}},
Offense = {Button = MainGUI.Offense, BGColor = ColorSequence.new{ColorSequenceKeypoint.new(0, MainGUI.Offense.MainColor.Value), ColorSequenceKeypoint.new(1, Color3.new(0,0,0))}, Text = MainGUI.Offense.Description.Value},
Defense = {Button = MainGUI.Defense, BGColor = ColorSequence.new{ColorSequenceKeypoint.new(0, MainGUI.Defense.MainColor.Value), ColorSequenceKeypoint.new(1, Color3.new(0,0,0))}, Text = MainGUI.Defense.Description.Value},
Support = {Button = MainGUI.Support, BGColor = ColorSequence.new{ColorSequenceKeypoint.new(0, MainGUI.Support.MainColor.Value), ColorSequenceKeypoint.new(1, Color3.new(0,0,0))}, Text = MainGUI.Support.Description.Value},
Dreamer = {Button = MainGUI.Dreamer, BGColor = ColorSequence.new{ColorSequenceKeypoint.new(0, MainGUI.Dreamer.MainColor.Value), ColorSequenceKeypoint.new(1, Color3.new(0,0,0))}, Text = MainGUI.Dreamer.Description.Value},
Riyeten = {Button = MainGUI.Riyeten, BGColor = ColorSequence.new{ColorSequenceKeypoint.new(0, MainGUI.Riyeten.MainColor.Value), ColorSequenceKeypoint.new(1, Color3.new(0,0,0))}, Text = MainGUI.Riyeten.Description.Value},
WIP = {Button = MainGUI.WIP, BGColor = ColorSequence.new{ColorSequenceKeypoint.new(0, MainGUI.WIP.MainColor.Value), ColorSequenceKeypoint.new(1, Color3.new(0,0,0))}, Text = MainGUI.WIP.Description.Value}
}
confirmation = false
function SetClassInfo(Col, Txt)
if confirmation == false then
MainGUI.Background.UIGradient.Color = Col
MainGUI.TopText.ClassDesc.Text = Txt
end
end
for i, v in pairs(Classes) do
v.Button.MouseEnter:Connect(function()
print(i)
print(v)
local class = Classes[i]
print(class)
SetClassInfo(class.BGColor,class.Text)
end)
v.Button.MouseLeave:Connect(function()
local FT = FlavourText[math.random(1,#FlavourText)]
local class = Classes.None
SetClassInfo(class.BGColor,FT)
end)
end