So I've recently made a dialog system with has three scripts module, local, and server script and I want to make it so that the player can interact again and again please help
--//my-scripts//-- --Module--
local module = {}
function module.SayDialog(text,tweentime,between,specialwords)
local words = {}
while string.len(text) > 1 do
local edittext = text
local num = string.find(edittext," ")
local word = string.sub(edittext,1,num)
text = string.sub(edittext,num+1)
table.insert(words,word)
end
local currentx = 0
local currenty = 0
local framex = script.Parent.AbsoluteSize.X
local tweeninfo = TweenInfo.new(tweentime,Enum.EasingStyle.Quad,Enum.EasingDirection.Out)
for i,x in pairs(words) do
local d = script.Parent.Default:Clone()
d.Parent = script.Parent.Text
d.Text = x
local sizex = d.TextBounds.X
d.Size = UDim2.new(0,sizex,0,40)
if currentx+sizex > framex then
currenty=currenty+40
currentx = 0
end
for v,r in pairs(specialwords) do
if r.Word == x then
d.TextColor3 = r.Color
end
end
d.Position = UDim2.new(0,currentx,0,currenty+40)
d.Rotation = math.random(-30,30)
currentx = currentx + sizex
d.Visible = true
game:GetService("TweenService"):Create(d,tweeninfo,{Position = UDim2.new(0,d.Position.X.Offset,0,d.Position.Y.Offset-40), Rotation = math.random(-3,3), TextTransparency = 0}):Play()
wait(between)
end
end
return module
--local-script--
local module = require(script.Parent.ModuleScript)
local ifplaying = false
game.ReplicatedStorage.NPCSpeak.OnClientEvent:connect(function(text)
if ifplaying == false then
ifplaying = true
script.Parent:TweenPosition(UDim2.new(0.5,0,0.772,0),Enum.EasingDirection.Out,Enum.EasingStyle.Back,1)
wait(1)
local wordtime = 0
for v,r in pairs(text) do
script.Parent.Text:ClearAllChildren()
wordtime = string.len(r.Text)*0.04
local coloredwords = {}
for s,q in pairs(r.Colored) do
local tab = {Word = q.Word,Color = q.Color}
table.insert(coloredwords,tab)
end
module.SayDialog(r.Text,0.6,0.15,coloredwords)
wait(wordtime)
end
script.Parent:TweenPosition(UDim2.new(0.5,0,1.2,0),Enum.EasingDirection.In,Enum.EasingStyle.Back,1)
end
end)
--server-script--
for i,x in pairs(game.Workspace.NPCs:GetChildren()) do
x.Region.Touched:connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
local tab = {}
for o,p in pairs(x.QuestLine:GetChildren()) do
for s,q in pairs(p:GetChildren()) do
local texttab = {
Text = q.Value.. " ",
Colored = {},
}
for v,r in pairs(q.Colored:GetChildren()) do
local colortab = {
Word = r.Name.." ",
Color = r.Value,
}
table.insert(texttab.Colored,colortab)
end
table.insert(tab,texttab)
end
game.ReplicatedStorage.NPCSpeak:FireClient(game.Players[hit.Parent.Name],tab)
end
end
end)
end
please help as soon as possible!
