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

Screenshot 2022-07-27 133529

this code keeps giving an error saying “attempted to use string value.” The module script is being used in a local script, but none of that matters. The only problem is that it tells me I can’t use a string value here. The value “PlayerName” changes, everything else works perfectly fine but it doesn’t let me use a string value.

Please let me know if I’m referencing the value wrong, or your just not allowed to use a string value in the circumstance.

Hello! Can you screenshot “PlayerName” in the explorer and properties tab to allow me to help better?

Screenshot 2022-07-27 135655

Screenshot 2022-07-27 135709

when you press e, the value changes here but it gives me errors, so I’m confused why it doesn’t let me use string values.

Do you think you could share an actual screenshot of the error as it’s probable that you’ve missed something?

Can you share the code that’s requiring this module?

I think you might use tostring() to make it a string too.

thats not the problem; if I weren’t referencing a stringvalue then it would work perfectly fine. I’ll still share it though.

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]
			local DialogModule = require(ReplicatedStorage.DialogModule)
			local dialog = DialogModule[NPC.Name]
			game.ReplicatedStorage.PlayerName.Value = p.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)

that would look like this, right?

local DialogModule = {
	["Dummy"] = {
		[1] = "Hello "..tostring(game.ReplicatedStorage.PlayerName.Value)"",
		--[2] = "Message Two",
		--[3] = "Message three"

might be causing issues because it’s value is empty. also worth noting that the dialogue will not be the player’s name unless you require() it after setting the string value.

Just remove the quotes at the end of


the value changes, that works perfectly fine. The problem is, it doesn’t let me use the string value.

Also, I do require the module script after the string value changes. The only problem is, it gives me errors because it’s a string value.

It took away the errors, but the dialog didn’t change. Can you show me the full script with the correct way to write it? I’m not familiar with tostring.

ToString is just converting your previous value into a string, which is what allows you to concatenate it with other thiings.

Not sure how I’m supposed to help you with the dialogue though because I’m not sure how your game is organized.

Also, if you don’t mind me asking, why are you storing the players name inside of a string value?

Try printing the exact same value in the same script before the dictionary, I want to see if for some reason it even exists in the scope.



I have two scripts. A local script, which is in charge of the dialog and recognizing what to do when “e” is pressed and a module script, which is in charge of what the dialog says. The module script is being required in the local script, and the module script is the first picture I sent in this topic. The only way to store a player name value within both scripts (because in the local script I change the value to the local player) is to have a string value. I hope this makes sense

theres no need; I know the PlayerName value changes because when I press play, and look in the value, it changes to my name. Only when I press e, of course.

No. This is my step of debugging. I always like to know exactly what im trying to do. One way is to see if string value even exists to the script because the error makes no sense.

when you say “string value” you mean game.ReplicatedStorage.PlayerName right? I’ll try your method but I’m like 85% sure it’ll print my name.