Why can't you reference a string value in a table

Screenshot 2022-07-27 162252

Screenshot 2022-07-27 162350

weird…prints nothing, value changes though, and at the same time my dialog doesn’t change. Could it be a problem with how it’s being organized?

Oh I think I figured it out. Replace that other part of the code with this:

for _, NPC in pairs(NPCs:GetChildren()) do
	local humanoidRootPart = NPC:FindFirstChild("HumanoidRootPart")
	local proximityPrompt = humanoidRootPart:FindFirstChild("ProximityPrompt")

	if humanoidRootPart and proximityPrompt then
		proximityPrompt.ObjectText = NPC.Name
		proximityPrompt.ActionText = "Talk "

		--local dialog = DialogModule[NPC.Name]

			game.ReplicatedStorage.PlayerName.Value = p.Name
			local DialogModule = require(ReplicatedStorage.DialogModule)
			local dialog = DialogModule[NPC.Name]


			if dialogOpen then

			dialogOpen = true
			proximityPrompt.Enabled = false
			NPCName.Value = NPC.Name
			p.Character.HumanoidRootPart.Anchored = true

			if dialogTween then
				dialogTween = nil
			local tween = TweenService:Create(DialogFrame, DIALOG_TWEENINFO, {
				Position = UDim2.new(0, 0, 1, 0)
			dialogTween = tween

			dialogIndex = 1
			onDialog(dialog, dialogIndex, proximityPrompt)
1 Like

I don’t know if this works, but you can try a string.format() method:

[1] = string.format("Hello, %s!", game.ReplicatedStorage.PlayerName.Value),

Edit: I don’t know why you are getting this error. When I print this:

print({[1] = "Hello" .. game.Players.daisytheghostchild98.Name})

I get this:


Mabye it’s an issue with your StringValue mabye not being an actual string (e.g. string is empty and comes up as nil)?

1 Like

For an explanation im pretty sure when you required the module, your name wasn’t even there yet so do the name before calling it.

yeah that makes sense. Thanks bro

Yes. And It should work if I’m not wrong.

As I figured, the script in question was the problem, specifically this line and the function that is subsequently called with ‘bad’ arguments.

onDialog(dialog, dialogIndex, proximityPrompt)