So I have this thing where I have NPCs in a folder inside workspace, each NPC has their own dialogue in a StringValue (as lines), and I have a ScreenGui that shows this dialogue when a person clicks the NPC. Now the issue is that the script works for a ClickDetector, but I want it to work for a ProximityPrompt instead, and I have no idea how to switch from this to that, how do I do it? (I’ll attach pictures below for a better explanation)
NPC’s folder in Workspace:
Each NPC contains a folder with StringValues (which are the lines that the NPC will say in the dialogue) and a ProximityPrompt called (ActivateText)
The ScreenGui which is the dialogue of the NPC that will show to the player
This is how the Gui looks like
This is the Figuartion script inside the ScreenGui
local mod = require(script.ModuleScript)
local player = game:GetService("Players").LocalPlayer
local npcs = workspace:WaitForChild("Npcs")
local gui = script.Parent
local MainFrame = gui.MainFrame
local dialogue = MainFrame.Dialouge
local mouse = player:GetMouse()
local char = player.Character
local sound = script.Sound
local target
canTalk = true
local function findTarget()
target = mouse.Target
return target
end
local function mouseButtonClick()
local theTarget = findTarget()
if theTarget.Parent.Parent == npcs then
local clicker = theTarget.Parent:FindFirstChild("ActivateText")
clicker.MouseClick:Connect(function()
if canTalk == true then
canTalk = false
local npc = clicker.Parent
local DialogueOptions = npc.DialogueOptions
local humanoid = char:WaitForChild("Humanoid")
local Line1 = DialogueOptions.Line1
local Line2 = DialogueOptions.Line2
local Line3 = DialogueOptions.Line3
local Line4 = DialogueOptions.Line4
local Line5 = DialogueOptions.Line5
local Line6 = DialogueOptions.Line6
local Line7 = DialogueOptions.Line7
local Line8 = DialogueOptions.Line8
local Line9 = DialogueOptions.Line9
humanoid.WalkSpeed = 0
MainFrame.Visible = true
MainFrame.Title.Text = npc.Name
mod.typewrite(dialogue, Line1.Value, .02, sound)
wait(4)
mod.typewrite(dialogue, Line2.Value, .02, sound)
wait(4)
mod.typewrite(dialogue, Line3.Value, .02, sound)
wait(4)
mod.typewrite(dialogue, Line4.Value, .02, sound)
wait(4)
mod.typewrite(dialogue, Line5.Value, .02, sound)
wait(4)
mod.typewrite(dialogue, Line6.Value, .02, sound)
wait(4)
mod.typewrite(dialogue, Line7.Value, .02, sound)
wait(4)
mod.typewrite(dialogue, Line8.Value, .02, sound)
wait(4)
mod.typewrite(dialogue, Line9.Value, .02, sound)
wait(4)
MainFrame.Visible = false
MainFrame.Dialouge.Text = " "
humanoid.WalkSpeed = 16
canTalk = true
end
end)
end
return theTarget
end
mouse.Button1Down:Connect(mouseButtonClick)
This is the ModuleScript inside the Figuration script
local module = {}
function module.typewrite(object , text, length, sound)
for i = 1,#text,1 do
object.Text = string.sub (text,1,i)
sound:Play()
wait (length)
end
end
return module
Would really hope if someone could help me figure this out.