I have a problem with my NPC interactions script, it’s in ScreenGUI, it keeps giving me an error saying the specific GUI is not a valid member while it is in Studio and Even in game (checked with explorer)
Error:
This is my code
--Click detectors
local shopguy = workspace.shopguy.ClickDetector
local specialshop = workspace.SpecialStands.ClickDetector
local bank = workspace.Banker.ClickDetector
local masteryskins = workspace.MasteryStands.ClickDetector
local theskinshop = workspace.SkinShop.ClickDetector
local joemama = workspace.JoeMamaRock.ClickDetector
local bluefish = workspace.fish.ClickDetector
local angelo = workspace.AngeloStone.ClickDetector
--NPC BAR STUFF
local nike = workspace.Nike.ClickDetector
local errors = workspace.ErrorsNPC.ClickDetector
--Variables
--Other stuff
local gui = script.Parent["DialogueGui"]
local NPCname = gui.NPCName.Text
local dialogue = gui.Dialogue.Text
local image = gui.Picture.ShopOwner
local image2 = gui.Picture.Jotaro
local image3 = gui.Picture.Banker
local image4 = gui.Picture.EventShopOwner
local image5 = gui.Picture.SpecialShop
local dialoguedb = false
image.Visible = false
Player = game:GetService("Players")["LocalPlayer"]
local playername = Player.Name
local char = Player.Character
local hum = char:WaitForChild("Humanoid")
--Events
local repstorage = game:GetService("ReplicatedStorage")
local zeppelievent = repstorage.ShopEvent
--Data Detection
local stand = Player:WaitForChild("Data")["Stand"]
--Functions
function closenormalshop()
local shopgui = script.Parent.SHOP1UI
local theshop = shopgui.Frame
theshop:TweenPosition(UDim2.new(-0.3, 0, 0.118, 0), 'Out', 'Quart', 1)
end
shopguy.MouseClick:Connect(function()
if not dialoguedb then
dialoguedb = true
gui.Enabled = true
local shopgui = script.Parent.SHOP1UI
local theshop = shopgui.Frame
theshop:TweenPosition(UDim2.new(-0.3, 0, 0.118, 0), 'Out', 'Quart', 1)
NPCname.Text = "Shop Owner"
theshop.Position = UDim2.new(-0.3, 0, 0.118, 0)
local line1 = "Looking for something?"
local voice = game.Workspace.SoundLibrary.Voice:Clone()
voice.Parent = shopguy.Parent.Head
voice.TimePosition = 0.2
voice.SoundId = "rbxassetid://4301105173"
voice.PlaybackSpeed = 1.25
for i = 1, #line1 do
dialogue.Text = string.sub(line1, 1, i)
wait(0.05)
voice:Play()
end
wait(1)
gui.Enabled = false
dialoguedb = false
image.Visible = false
voice:Destroy()
shopgui.Enabled = true
wait(0.15)
theshop:TweenPosition(UDim2.new(0, 0, 0.118, 0), 'Out', 'Quart', 1)
end
end)
bank.MouseClick:Connect(function()
if not dialoguedb then
dialoguedb = true
gui.Enabled = true
local shopgui = script.Parent.Bank
local theshop = shopgui.Frame
theshop:TweenPosition(UDim2.new(-0.3, 0, 0.118, 0), 'Out', 'Quart', 1)
NPCname.Text = "The Bank"
theshop.Position = UDim2.new(-0.3, 0, 0.118, 0)
local line1 = "Cashing out today?"
local voice = game.Workspace.SoundLibrary.Voice:Clone()
voice.Parent = bank.Parent.Head
voice.TimePosition = 0.2
voice.SoundId = "rbxassetid://4301105173"
voice.PlaybackSpeed = 1.25
for i = 1, #line1 do
dialogue.Text = string.sub(line1, 1, i)
wait(0.05)
voice:Play()
end
wait(1)
gui.Enabled = false
dialoguedb = false
image.Visible = false
voice:Destroy()
shopgui.Enabled = true
wait(0.15)
theshop:TweenPosition(UDim2.new(0, 0, 0.118, 0), 'Out', 'Quart', 1)
end
end)
specialshop.MouseClick:Connect(function()
if not dialoguedb then
dialoguedb = true
gui.Enabled = true
local shopgui = script.Parent.LimitedEditionShop
local theshop = shopgui.Frame
theshop:TweenPosition(UDim2.new(-0.3, 0, 0.118, 0), 'Out', 'Quart', 1)
NPCname.Text = "Skin Shop"
theshop.Position = UDim2.new(-0.3, 0, 0.118, 0)
local line1 = "Limited Edition skins currently on sale:"
local voice = game.Workspace.SoundLibrary.Voice:Clone()
voice.Parent = specialshop.Parent["Stand Torso"]
voice.TimePosition = 0.2
voice.SoundId = "rbxassetid://4301105173"
voice.PlaybackSpeed = 1.25
for i = 1, #line1 do
dialogue.Text = string.sub(line1, 1, i)
wait(0.05)
voice:Play()
end
wait(1)
gui.Enabled = false
dialoguedb = false
image.Visible = false
voice:Destroy()
shopgui.Enabled = true
wait(0.15)
theshop:TweenPosition(UDim2.new(0, 0, 0.118, 0), 'Out', 'Quart', 1)
end
end)
masteryskins.MouseClick:Connect(function()
if not dialoguedb then
dialoguedb = true
gui.Enabled = true
local shopgui = script.Parent.MasteryShopGUI
local theshop = shopgui.Frame
theshop:TweenPosition(UDim2.new(-0.3, 0, 0.118, 0), 'Out', 'Quart', 1)
NPCname.Text = "Mastery Variants"
theshop.Position = UDim2.new(-0.3, 0, 0.118, 0)
local line1 = "Current mastery variants:"
local voice = game.Workspace.SoundLibrary.Voice:Clone()
voice.Parent = masteryskins.Parent["Stand Torso"]
voice.TimePosition = 0.2
voice.SoundId = "rbxassetid://4301105173"
voice.PlaybackSpeed = 1.25
for i = 1, #line1 do
dialogue.Text = string.sub(line1, 1, i)
wait(0.05)
voice:Play()
end
wait(1)
gui.Enabled = false
dialoguedb = false
image.Visible = false
voice:Destroy()
shopgui.Enabled = true
wait(0.15)
theshop:TweenPosition(UDim2.new(0, 0, 0.118, 0), 'Out', 'Quart', 1)
end
end)
theskinshop.MouseClick:Connect(function()
if not dialoguedb then
dialoguedb = true
gui.Enabled = true
local shopgui = script.Parent.SkinnoShop
local theshop = shopgui.Frame
theshop:TweenPosition(UDim2.new(-1, 0, 0.132, 0), 'Out', 'Quart', 1)
NPCname.Text = "Skin Shop"
theshop.Position = UDim2.new(-1, 0, 0.132, 0)
local line1 = "Skins for sale:"
local voice = game.Workspace.SoundLibrary.Voice:Clone()
voice.Parent = theskinshop.Parent["Head"]
voice.TimePosition = 0.2
voice.SoundId = "rbxassetid://4301105173"
voice.PlaybackSpeed = 1.25
for i = 1, #line1 do
dialogue.Text = string.sub(line1, 1, i)
wait(0.05)
voice:Play()
end
wait(1)
gui.Enabled = false
dialoguedb = false
image.Visible = false
voice:Destroy()
shopgui.Enabled = true
wait(0.15)
theshop:TweenPosition(UDim2.new(0.145, 0, 0.132, 0), 'Out', 'Quart', 1)
end
end)
bluefish.MouseClick:Connect(function()
if not dialoguedb then
dialoguedb = true
gui.Enabled = true
NPCname.Text = "Blue Fish"
local line1 = "Glub Glub Glub"
local voice = game.Workspace.SoundLibrary.Voice:Clone()
voice.Parent = bluefish.Parent
voice.TimePosition = 0.2
voice.SoundId = "rbxassetid://1847405409"
voice.PlaybackSpeed = 1.25
voice:Play()
for i = 1, #line1 do
dialogue.Text = string.sub(line1, 1, i)
wait(0.05)
end
wait(1)
gui.Enabled = false
dialoguedb = false
image.Visible = false
voice:Destroy()
end
end)
angelo.MouseClick:Connect(function()
if not dialoguedb then
dialoguedb = true
gui.Enabled = true
NPCname.Text = "You"
local line1 = "Yo, Angelo. 🗿"
local voice = game.Workspace.SoundLibrary.Voice:Clone()
voice.Parent = angelo.Parent
voice.TimePosition = 0.2
voice.SoundId = "rbxassetid://4301105173"
voice.PlaybackSpeed = 1.25
voice:Play()
for i = 1, #line1 do
dialogue.Text = string.sub(line1, 1, i)
wait(0.05)
voice:Play()
end
wait(1.75)
gui.Enabled = false
dialoguedb = false
image.Visible = false
voice:Destroy()
end
end)
--531.4, 200.1, 175.4
--Add
--906.9
--49
--11/2/19
--NUH
joemama.MouseClick:Connect(function()
if not dialoguedb then
dialoguedb = true
gui.Enabled = true
NPCname.Text = "Joe Mama Arrow"
local line1 = "NULL"
local voice = game.Workspace.SoundLibrary.Voice:Clone()
voice.Parent = joemama.Parent["Rock"]
voice.TimePosition = 0.2
voice.SoundId = "rbxassetid://4301105173"
voice.PlaybackSpeed = 1.25
for i = 1, #line1 do
dialogue.Text = string.sub(line1, 1, i)
wait(0.05)
voice:Play()
end
wait(4)
gui.Enabled = false
dialoguedb = false
image.Visible = false
voice:Destroy()
end
end)
nike.MouseClick:Connect(function()
if not dialoguedb then
dialoguedb = true
gui.Enabled = true
NPCname.Text = "Nike156"
local line1 = "Welcome! Hey, you heard about ChimpCon 2020 next month? Hopefully I can get myself a ticket, I wouldn't wanna leave Fallen, Ody and Steak by themselves..."
local voice = game.Workspace.SoundLibrary.Voice:Clone()
voice.Parent = nike.Parent
voice.TimePosition = 0.2
voice.SoundId = "rbxassetid://4301105173"
voice.PlaybackSpeed = 1.25
voice:Play()
for i = 1, #line1 do
dialogue.Text = string.sub(line1, 1, i)
wait(0.05)
voice:Play()
end
wait(1.5)
gui.Enabled = false
dialoguedb = false
image.Visible = false
voice:Destroy()
end
end)
errors.MouseClick:Connect(function()
if not dialoguedb then
dialoguedb = true
gui.Enabled = true
NPCname.Text = "Errors"
local line1 = "Hello."
local voice = game.Workspace.SoundLibrary.Voice:Clone()
voice.Parent = errors.Parent
voice.TimePosition = 0.2
voice.SoundId = "rbxassetid://4301105173"
voice.PlaybackSpeed = 1.25
voice:Play()
for i = 1, #line1 do
dialogue.Text = string.sub(line1, 1, i)
wait(0.05)
voice:Play()
end
wait(1)
gui.Enabled = false
dialoguedb = false
image.Visible = false
voice:Destroy()
end
end)
I also did try changing the “Script.Parent[“DialogueGui”]” to “Script.Parent.DialogueGui” but that still didnt fix it.
This is how it is in Studio
