Hi all i´m making a script to talk with npcs but i have a problem, i need to cut in some Dialogs the sentences {Player Name} and change it for the actual player´s name and it doesn´t work, so that´s my code.
I´m using string for the dialogs.
local DialogArray = {
["Gretting"] = "Hi {Player Name} I´m jake" -- Dialog
}
function Talk()
local PlayerFound = string.find(DialogArray[1], "{Player Name}") -- Searchs on the string {Player Name}
if PlayerFound then
local ChangedText = string.sub(PlayerFound, #PlayerFound) -- It try to cut the Word {Player Name}
DialogArray[1] = ChangedText
print(ChangedText)
end
end
When i try to print that appears:
ServerScriptService.Script:6: bad argument #1 to 'find' (string expected, got nil) 19:12:12.655 - Stack Begin 19:12:12.656 - Script 'ServerScriptService.Script', Line 6 - global Talk 19:12:12.656 - Script 'ServerScriptService.Script', Line 15 19:12:12.657 - Stack End
This is what I'm trying to print:
Hi imago15 I´m jake"
Please Help me i need this Urgent, I'm sorry if it seems Badly written is because I do not use string well Thanks.

2 comments
Are you using a custom dialog (such as done with guis) or the pre-made ROBLOX Dialog / DialogChoices?
Sorry Nope, I´m Using an Array with strings for dialogs