Hello! I am currently developing a dialogue system for my game, problem is I’ve come to a roadblock at developing consecutive dialogues…
Now, the problem with this issue is that it’s skipping some of the dialogue:
(See how 2 only prints once? That means one of the dialogues got skipped.)
I’m assumed this is a problem with how UIS.InputBegan creates a connection, although I was wrong.
I’m gonna send all of my scripts since I’m not sure what to do to fix this issue:
wait(2)
local TextLabel = game.Players.LocalPlayer.PlayerGui.DialogueGui.TextLabel
local EnabledProximityPrompts = {}
local OriginalWalkSpeed
local OriginalJumpPower
local conn0
local conn
game.ReplicatedStorage.Events.ChatEvent.OnClientEvent:Connect(function(Text, TypingDelay, Color, StrokeColor, Sound, IsContinuous)
game.ReplicatedStorage.Events.ChatEvent:FireServer("ChatActivated",true)
game.ReplicatedStorage.Events.ChatEvent:FireServer("ChatSpeaking",true)
if game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed ~= 0 then
OriginalWalkSpeed = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed
game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed = 0
end
if game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").JumpPower ~= 0 then
OriginalJumpPower = game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").JumpPower
game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").JumpPower = 0
end
for i, v in pairs(workspace:GetDescendants()) do
if v:IsA("ProximityPrompt") then
if v.Enabled == true then
v.Enabled = false
table.insert(EnabledProximityPrompts, v)
end
end
end
TextLabel.Text = ""
TextLabel.TextColor3 = Color
TextLabel.TextStrokeColor3 = StrokeColor
for i = 1,#Text do
TextLabel.Text = string.sub(Text,1,i)
Sound:Play()
wait(TypingDelay)
conn0 = game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Touch and game.Players.LocalPlayer:FindFirstChild("ChatActivated").Value == true and game.Players.LocalPlayer:FindFirstChild("ChatSpeaking").Value == true or input.UserInputType == Enum.UserInputType.MouseButton1 and game.Players.LocalPlayer:FindFirstChild("ChatActivated").Value == true and game.Players.LocalPlayer:FindFirstChild("ChatSpeaking").Value == true or input.KeyCode == Enum.KeyCode.E and game.Players.LocalPlayer:FindFirstChild("ChatActivated").Value == true and game.Players.LocalPlayer:FindFirstChild("ChatSpeaking").Value == true then
TextLabel.Text = Text
end
conn0:Disconnect()
end)
if TextLabel.Text == Text then
break
end
end
game.ReplicatedStorage.Events.ChatEvent:FireServer("ChatSpeaking",false)
conn = game:GetService("UserInputService").InputBegan:Connect(function(input)
if input.UserInputType == Enum.UserInputType.Touch and game.Players.LocalPlayer:FindFirstChild("ChatActivated").Value == true and game.Players.LocalPlayer:FindFirstChild("ChatSpeaking").Value == false or input.UserInputType == Enum.UserInputType.MouseButton1 and game.Players.LocalPlayer:FindFirstChild("ChatActivated").Value == true and game.Players.LocalPlayer:FindFirstChild("ChatSpeaking").Value == false or input.KeyCode == Enum.KeyCode.E and game.Players.LocalPlayer:FindFirstChild("ChatActivated").Value == true and game.Players.LocalPlayer:FindFirstChild("ChatSpeaking").Value == false then
TextLabel.Text = ""
game.ReplicatedStorage.Events.ChatEvent:FireServer("ChatActivated", false)
if IsContinuous == false then
for i,v in pairs(EnabledProximityPrompts) do
v.Enabled = true
end
if OriginalWalkSpeed ~= nil then
game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed = OriginalWalkSpeed
elseif OriginalWalkSpeed == nil then
game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").WalkSpeed = 0
end
if OriginalJumpPower ~= nil then
game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").JumpPower = OriginalJumpPower
elseif OriginalJumpPower == nil then
game.Players.LocalPlayer.Character:FindFirstChild("Humanoid").JumpPower = 0
end
end
end
conn:Disconnect()
end)
end)
(Located on StarterPlayerScripts)
local ChatActivated = Instance.new("BoolValue", game.Players:GetPlayerFromCharacter(script.Parent))
ChatActivated.Name = "ChatActivated"
ChatActivated.Value = false
local ChatSpeaking = Instance.new("BoolValue", game.Players:GetPlayerFromCharacter(script.Parent))
ChatSpeaking.Name = "ChatSpeaking"
ChatSpeaking.Value = false
game.ReplicatedStorage.Events.ChatEvent.OnServerEvent:Connect(function(player, Value, Status)
if Value == "ChatActivated" and Status == true then
ChatActivated.Value = true
elseif Value == "ChatActivated" and Status == false then
ChatActivated.Value = false
elseif Value == "ChatSpeaking" and Status == true then
ChatSpeaking.Value = true
elseif Value == "ChatSpeaking" and Status == false then
ChatSpeaking.Value = false
end
end)
(Located on StarterCharacterScripts)
local DialogueIndex = 0
script.Parent.Triggered:Connect(function(player)
DialogueIndex = 1
game.ReplicatedStorage.Events.ChatEvent:FireClient(player, "This is gonna be a test", 0.1, Color3.new(255,255,255), Color3.new(255,255,255), workspace.SFX.TypingSounds, true)
player:FindFirstChild("ChatActivated").Changed:Connect(function()
print(DialogueIndex)
if player:FindFirstChild("ChatActivated").Value == false then
if DialogueIndex == 1 then
DialogueIndex = 2
game.ReplicatedStorage.Events.ChatEvent:FireClient(player, "This is gonna be a test", 0.1, Color3.new(1, 0, 0), Color3.new(1, 0, 0), workspace.SFX.TypingSounds, true)
elseif DialogueIndex == 2 then
DialogueIndex = 0
game.ReplicatedStorage.Events.ChatEvent:FireClient(player, "This is gonna be a test", 0.1, Color3.new(0, 0, 1), Color3.new(0, 0, 1), workspace.SFX.TypingSounds, false)
end
end
end)
end)
(Located on a ProximityPrompt)
I’m sorry for the big scripts, I just didn’t want to not send enough info to fix the issue.
Any help is appreciated!