I am creating a story mode type game. And It uses a dialogue system. Whenever the player talks to that specific dialogue their story mode Position gets updated to the data store so that when they load back in they are still at the point they were when they left. In order for them to save that point they need to talk to a specific npc that only shows up for them if they have reached a story mode point. I already set up a dialogue system for them to talk with the npc but I am running into a bug with it.
Whenever I run this code: (Server)
local function Dialouge(Plr, TextLabel, Text, YesNo, Ok, BorderColorGradient, BackgroundColorGradient, TextColorGradient, Rate, DialougePrompt, StoryMode)
print ("Recived DialougeFunction")
local MainBackground = TextLabel.Parent.Parent.MainBackground
MainBackground.UIGradient.Color = BackgroundColorGradient
local MainBorder = TextLabel.Parent.Parent.MainBorder
MainBorder.UIGradient.Color = BorderColorGradient
local Texts = {}
table.insert(Texts, TextLabel)
table.insert(Texts, TextLabel.Parent.Parent.YesButton)
table.insert(Texts, TextLabel.Parent.Parent.ByeButton)
table.insert(Texts, TextLabel.Parent.Parent.OkButton)
for i,String in pairs (Texts) do
String.UIGradient.Color = TextColorGradient
end
print ("DoingYesNoCheck")
if YesNo == true then
print ("PassedYesNo")
InitiateYesNoDialougeEvent:FireClient(Plr, DialougePrompt, TextLabel)
print ("FiredInitiateYesNoEvent")
wait(3)
print ("TypingOut Text")
TypeOut(TextLabel, Text, Rate)
wait(string.len(Text)*Rate)
for i,TextObject in pairs (Texts) do
if TextObject.Name == "YesButton" or "ByeButton" then
TextObject.Active = true
end
end
print ("Enabled YesNoButtons")
ChooseYesNoClientEvent:FireClient(Plr) --Here
print ("FiredChooseYesNo Event")
ChooseYesNoServerEvent.OnServerEvent:Connect(function(PlrWhoFired, YesNo)
print ("RecivedYesNoFromPlayer")
for i,TextObject in pairs (Texts) do
if TextObject.Name == "YesButton" or "ByeButton" then
TextObject.Active = false
end
end
if YesNo == "Yes" then
print ("PlayerPressedYes")
if StoryMode ~= nil then
PlrWhoFired.AttributeFolder.StoryPoint.Value = StoryMode
end
EndDialougeEvent:FireClient(Plr, Texts, DialougePrompt)
wait (1.1)
TextLabel.Text = ""
elseif YesNo == "No" then
print ("PlayerPressedNo")
EndDialougeEvent:FireClient(Plr, Texts, DialougePrompt)
wait (1.1)
TextLabel.Text = ""
else
warn("Error")
end
end)
What this code does is that It gets the attributes from the specific proximity prompt and creates the dialogue with it. Where I put “Here” is where it fires to the client this code: (Client)
local function ChooseYesNo()
print ("RecivedChooseYesNo")
local tweenProperties = {
TextStrokeTransparency = 0,
TextTransparency = 0
}
local Tween1 = TweenService:Create(YesButton, tweenInfo, tweenProperties)
local Tween2 = TweenService:Create(ByeButton, tweenInfo, tweenProperties)
Tween1:Play()
Tween2:Play()
print ("PlayingTweens")
wait(0.7)
Tween1:Pause()
Tween2:Pause()
YesButton.MouseButton1Click:Connect(function()
print ("PlayerPressedYes")
local YesNo = "Yes"
ChooseYesNoServerEvent:FireServer(YesNo)
ByeButton.Active = false
Tween1:Play()
Tween2:Play()
end)
ByeButton.MouseButton1Click:Connect(function()
print ("PlayerPressedNo")
local YesNo = "No"
ChooseYesNoServerEvent:FireServer(YesNo)
ByeButton.Active = false
Tween1:Play()
Tween2:Play()
end)
end
What this does is makes it so that the player can pick either a yes or no button. Once they choose yes or no this code runs:
ChooseYesNoServerEvent.OnServerEvent:Connect(function(PlrWhoFired, YesNo)
print ("RecivedYesNoFromPlayer")
for i,TextObject in pairs (Texts) do
if TextObject.Name == "YesButton" or "ByeButton" then
TextObject.Active = false
end
end
if YesNo == "Yes" then
print ("PlayerPressedYes")
if StoryMode ~= nil then
PlrWhoFired.AttributeFolder.StoryPoint.Value = StoryMode
end
EndDialougeEvent:FireClient(Plr, Texts, DialougePrompt)
wait (1.1)
TextLabel.Text = ""
elseif YesNo == "No" then
print ("PlayerPressedNo")
EndDialougeEvent:FireClient(Plr, Texts, DialougePrompt)
wait (1.1)
TextLabel.Text = ""
else
warn("Error")
end
end)
So what this code does is that It receives the “YesNo” Variable that the player sent. If the variable is the string “Yes” then it sets the storypoint attribute, if it is no then it ends the dialogue.
The error that I’m getting is that when I click on the client the Yes button it spams the remote multiple times, and it does not set the story point attribute.
Can someone please help me?