-
What do you want to achieve?
I have some local scripts in startercharacterscripts or some gui related scripts in a screengui within’ startergui and I want it to run successfully even if I reset. -
What is the issue?
So the local scripts that I have set up are working perfectly when I’m using them but when I reset, they run twice. An example would be that it prints hi once but when I reset and I use it, it prints hi twice. -
What solutions have you tried so far?
I tried doing ResetOnDeath to true and false on the GUIs and that doesn’t affect anything, when I put the local scripts in starterplayerscripts, it actually stopped double printing but I want a solution without having to move all the localscripts to starterplayerscripts.
I also checked the devforum and I couldn’t find anything that helped me.
Server script:
local proximityPrompt = script.Parent.ProximityPrompt
proximityPrompt.Triggered:Connect(function(player : Player)
local character : Model = player.Character
local humanoid : Humanoid = character:FindFirstChild("Humanoid")
if humanoid.Health == 0 then return end
local questType : string = script.Parent.Parent.Parent.Parent.Name
local questName : string = script.Parent.Parent.Parent.Name
local data = DataManager:GetData(player)
if PlayerService:HasQuest(player, questName) then
print("has quest")
else
for index, quest : string in pairs(QuestLibrary[questType][questName].RequiredQuests) do
if data.CompletedQuests[questType][quest] == true then
enableDialogue_Net:FireTo(player, questType, questName)
else
requirementsNotMet_Net:FireTo(player)
end
end
if (next(QuestLibrary[questType][questName].RequiredQuests) == nil) then
enableDialogue_Net:FireTo(player, questType, questName)
end
end
end)
Local script: (located in a gui with ResetOnDeath set to true in StarterGui)
enableDialogue_Net:Connect(function(questType : string, questName : string)
print("hi")
local count = 1
local player : Player = game.Players.LocalPlayer
local character : Model = player.Character
local humanoid : Humanoid = character:FindFirstChild("Humanoid")
local playerGui = player.PlayerGui
local quest = playerGui:WaitForChild("Quest")
local questUI = quest:WaitForChild("QuestUI")
local main = questUI:WaitForChild("Main")
local dialogue = main:WaitForChild("Dialogue")
local acceptButton = main:WaitForChild("AcceptButton")
local declineButton = main:WaitForChild("DeclineButton")
EnableDialogue(dialogue, acceptButton, declineButton, questType, questName, questUI, main)
local acceptConnection : RBXScriptConnection
local declineConnection : RBXScriptConnection
humanoid.Died:Connect(function()
acceptConnection:Disconnect()
declineConnection:Disconnect()
DisableDialogue(questUI, main)
end)
acceptConnection = acceptButton.MouseButton1Down:Connect(function()
print("accepted")
count += 1
if count <= #QuestLibrary[questType][questName].Dialogue then
dialogue.Text = QuestLibrary[questType][questName].Dialogue[count]
acceptButton.Text = QuestLibrary[questType][questName].AcceptAnswers[count]
declineButton.Text = QuestLibrary[questType][questName].DeclineAnswers[count]
print(count)
else
count = 1
acceptConnection:Disconnect()
declineConnection:Disconnect()
setDataQuest_Net:Fire(questType, questName)
changeObjectiveText_Net:Fire(questType, questName)
receiveQuest_Net:Fire(questType, questName)
DisableDialogue(questUI, main)
end
end)
declineConnection = declineButton.MouseButton1Down:Connect(function()
declineConnection:Disconnect()
acceptConnection:Disconnect()
count = 1
DisableDialogue(questUI, main)
end)
end)
requirementsNotMet_Net:Connect(function()
print("requirements not met")
end)