Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

Please help, unknown error keeps happening? Cloning works, just not the value of name?

I made this script trying to give the GUI to the player (Which works fine) and then changing the text to the name of the NPC talking. And yes, the NPC has a string value with the value beings its name.

This is the error I keep getting as well:

18:00:44.402 - Workspace.Soldier.Part.Script:14: attempt to concatenate local 'NPCName' (a nil value) 18:00:44.4

Here's the script :

local Gui = game.Lighting.MapGui --Name of gui, be sure to put gui on lighting.

function GiveGui(Player)
if Player.PlayerGui:FindFirstChild(Gui.Name)~=nil then return end
Gui:Clone().Parent=Player.PlayerGui
end

script.Parent.Touched:connect(function(hit)

local Player=game.Players:GetPlayerFromCharacter(hit.Parent)
if Player==nil then return end
GiveGui(Player)
local NPCName = script.Parent.Parent.Name.Value
Player.PlayerGui.MapGui.Frame.Ya.Text = "Press 'Q' to speak with "..NPCName

end)

2 comments

0

Are you making sure that there's actually a name in that StringValue box? Because from the looks of it the script thinks it's empty.

0

Edited to fix code formatting

1 answer

Found the answer. For anyone wanting to know how to do this, everything was correct except I was being dumb and never named the value. Feel free to use my script to help you!

This discussion is preserved as it was. New answers, comments, and votes are closed.