Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 8 years ago
Edited by BlueTaslem 8 years ago

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)
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. Cuvette 246 — 8y
0
Edited to fix code formatting BlueTaslem 18071 — 8y

1 answer

Log in to vote
0
Answered by 8 years ago

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!

Ad

Answer this question