My Dialogue choice function doesn't work the second time

  1. What do you want to achieve? Keep it simple and clear!

I want to make a dialogue choice for my game

  1. What is the issue? Include screenshots / videos if possible!

My function works for the first time (just like the title says), but it just casts an error on the second time saying, attempt to call a number value.

The function itself isn’t calling the error, but calling it causes the error:

-- EventType  is one of the variables from a table; table[1]
if EventType == "Dialogue" then
		WriteDialogue(DialogueVoice, DialogueWritingTime, Value, DialogueBoxInfo, DialogueTextInfo, FaceInfo, InstanceInteracted)
	elseif EventType == "DialogueChoice" then
		print(Info)
		DialogueChoice(Value, DialogueVoice, DialogueWritingTime) -- This is causing errors
	elseif EventType == "DialogueShow" then
		DialogueBox.Visible = true
	elseif EventType == "DialogueHide" then
		DialogueBox.Visible = false
	end

This above gets a module script and reads the “event timeline” and when the dialogue recognises the type of event, it performs it; in this case dialogue, dialogue choices, etc.

This above also comes from a bindable function “.On invoke”

  1. What solutions have you tried so far? Did you look for solutions on the Creator Hub?

I tried to but some posts aren’t very helpful

could you show the part where your calling the function?

Sure

This is from another script where I used a hitbox to interact with objects:

function ReadInteractionHitbox(InteractionHitbox)
	local EventModule = require(InteractionHitbox.EventModule)
	local InteractionNum = EventModule[InteractionHitbox:GetAttribute("CurrentInteractionNum")]
-- Reads the module script's event timeline; InteractionNum
	for i, v in pairs(InteractionNum) do
		local EventType = v[1]
		local Value = v[2]
		-- reads each line and gets filtered through these gates and when it matches a type of event string, it invokes a bindable function for the other script to perform (The original post).
		if EventType == "CutsceneNumVal" then
			print("CutsceneNumVal")
			ChangeCutsceneVal:Invoke(v)
		elseif EventType == "Dialogue" or EventType == "DialogueShow" or EventType == "DialogueHide" or EventType == "DialogueChoice" or EventType == "DialogueAnswer" then
			Dialogue:Invoke(v)
		end
	end
end

I’m so illiterate, I had a variable that’s named exactly like a function so it literally calls the variable instead of the function.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.