So I have this code here
if dialogue[DetectedNPC.Name].responses then
for i,v in pairs(dialogue[DetectedNPC.Name].responses) do
-- create a text button for each one
local button = Instance.new("TextButton", game.Players.LocalPlayer.PlayerGui["Chat System"])
button.Name = i
button.Text = i
button.Position = UDim2.new(0,200,0,0)
button.BackgroundTransparency = 0
button.TextSize = 30
end
end
for i,v in pairs(game.Players.LocalPlayer.PlayerGui["Chat System"]:GetChildren()) do
if v:IsA("TextButton") then
v.MouseButton1Click:Connect(function()
print("test")
end)
end
end
And for some reason
v.MouseButton1Click:Connect(function()
print("test")
end)
doesn’t seem to work at all and I’m not really sure why I’ve tried putting prints in the loop and they all work so the loop is working, but the button1click isn’t which is weird because I did this exact same thing in another script
for i = 1,#characters do
local button = Instance.new("TextButton",rosterMenu)
button.Name = characters[i]
button.Text = characters[i]
end
for i,v in pairs(rosterMenu:GetChildren()) do
if v:IsA("TextButton") then
v.MouseButton1Click:Connect(function()
if selected == nil then
selected = v.Name
displayCharacter(selected)
print("Character Selected!")
elseif v.Name == selected then
print("Character Already Selected. Pick A New Character")
elseif v.Name ~= selected then
previousSelected = selected
selected = v.Name
displayCharacter(selected, previousSelected)
print("Previous Selected:"..previousSelected.." New Selected: "..selected)
end
end)
end
end
p.s: there are no errors
Hopefully someone is able to help and notice any issues because I don’t see what I did wrong lol.