This part of the script handles whether or not the textButtons should actually be turned on or not, problem with the code is that its not actually turning anything off?
Here the output shows that the script is getting where it needs to and knows which response is which (Yes, the response button vars are set to the players gui and not startergui)
The other issue is with Activated, along with Active being weird on me clicking on response two which should’ve been the only active response does actually run the Activated Connect function, but pressing on the two that were supposed to be inactive do actually output something
Why are there multiple text buttons? Consider storing a table of strings, loop through that table, and change the text like that all to one text button
local responseEvent = nil;
for i, response in ipairs(script.Parent:GetChildren()) do
responseEvent[i] = response.Activated:Connect(function()
response.Text = "this response"
if responseEvent then
responseEvent:Disconnect();
responseEvent = nil;
end;
end);
end;
Correct, when one is pressed it checks for dialogue within the response and repeats over and over via this system I made based on one I saw on Unity, Im not sure if it’s the best way to do this but hey, it works and its progress
It would be better to organize this in a table within your script or require a separate module that returns information. I have created a single dialogue response, I will try to create a second dialogue to make it easier to replicate on to your script.
local responseEvent = nil;
local responses = {
"response1",
"response2",
"response3"
};
for i, response in ipairs(script.Parent:GetChildren()) do
if response:IsA("TextButton") then
responseEvent = response.Activated:Connect(function()
script.Parent.TextLabel.Text = responses[i]
response.Text = "this response"
if responseEvent then
responseEvent:Disconnect();
responseEvent = nil;
end;
end);
end;
end;
Ah I see but wait wait wait, we keep getting off track. Right now I am worried that Im using the TextButtons .Active and .Activated:Connected wrong, I still have no idea why the actives aren’t being set to false and why Activate functions arent connecting. I really appreciate the organizations and better code choices and I’ll definitely come back to them when I revamp the code but I still need figure out why my code that used to be working no longer isnt
I think I’ve created something similar to your dialogue system, it doesn’t set active to false, but just runs the function again. You could add a debounce in place of disabling the button, still not too sure of what is wrong with your code, you could send me a script if you’d like. Here’s my code.
local responseEvent = nil;
local indent = 1;
local lastResponse = nil;
local responses = {
[1] = {
["Default"] = "response1",
[1] = "response1, 1",
[2] = "response1, 2",
[3] = "response1, 3"
},
[2] = {
["Default"] = "response2",
[1] = "response2, 1",
[2] = "response2, 2",
[3] = "response2, 3"
},
[3] = {
["Default"] = "response3",
[1] = "response3, 1",
[2] = "response3, 2",
[3] = "response3, 3"
}
};
local function callResponse()
for i, response in ipairs(script.Parent:GetChildren()) do
if response:IsA("TextButton") then
responseEvent = response.Activated:Connect(function()
if (lastResponse == nil) then
script.Parent.TextLabel.Text = responses[i]["Default"];
lastResponse = i;
callResponse();
else
script.Parent.TextLabel.Text = responses[lastResponse][i];
end;
response.Text = "this response";
if responseEvent then
responseEvent:Disconnect();
responseEvent = nil;
end;
end);
end;
end;
end;
callResponse()
Hey! Sorry for the really late response, I wasn’t able to get on over the weekend. I copied over everything related to the dialogue system into a separate game and it has started to work. I’ll send the dialogue system in-case you’re still curious. I’d move this into the Studio Bugs section but sadly I dont have access to creating topics in there. InteractionTest.rbxl (77.4 KB)