Hey All,
I’m attempting to figure out how to create a single mission for a player to complete. The problem is the mission is no longer active once the player dies. How can I make the mission stay active, even after player death?
The setup: The player goes up to an NPC, has a conversation, an ACCEPT button appears, the player clicks the button. The script, Mission1Script, detects the ACCEPT button being activated and makes the Mission GUI appears on the screen showing how many items they player has collected, makes cans of soda appear around the map for the player to pick up, and changes the color of the exclamation point above the NPC’s head to orange once all 10 sodas are picked up…
It seems to me that the it’s the Mission1Script that resets. I don’t see an option in the Script properties, like ResetOnSpawn, that I could uncheck. I’m assuming there’s something to be added to this script. Any suggestions?
Here is a copy of the Mission1Script for reference, if needed:
-- Variables
local textButton = script.Parent
local Players = game:GetService("Players")
local player = Players.LocalPlayer
local playerName = Players.LocalPlayer.Name
local sodaNumber = 0
local debounce = true
local missionGui = script.Parent.Parent.Parent:WaitForChild("MissionGui")
missionGui.Enabled = false
-- Functions
local sodas = game.Workspace.Drinks:GetChildren()
for _, drink1 in pairs(sodas) do
drink1.Transparency = 1
end
textButton.Activated:Connect(function()
local hum = player.Character:FindFirstChild("Humanoid")
local char = player.Character
local charName = char.Name
missionGui.Enabled = true
if hum and playerName == charName and debounce then
debounce = false
for _, drink in pairs(sodas) do
local canPickup = drink.Value.Value
drink.Transparency = 0
drink.Touched:Connect(function(part)
local hum = part.Parent:FindFirstChild("Humanoid")
local char = part.Parent
local charName = char.Name
if hum and playerName == charName and canPickup then
canPickup = false
drink.Transparency = 1
sodaNumber = sodaNumber + 1
missionGui.Frame.SodaLabel.Text = "Drinks: " .. sodaNumber
end
if sodaNumber == 10 then
-- missionCompleted = true
missionGui.Mission1CompletedValue.Value = true
missionGui.Frame.SodaLabel.BackgroundColor3 = Color3.fromRGB(17,255,32)
script.Parent.Parent.MissionValue.Value = "Lines2"
game.Workspace.Exclamations.ToDaExclamation.Part1.BrickColor = BrickColor.new("Deep orange")
game.Workspace.Exclamations.ToDaExclamation.Part2.BrickColor = BrickColor.new("Deep orange")
end
end)
end
end
end)