Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Make a scene when killed NPC after receiving a quest?

Asked by 5 years ago
Edited 5 years ago

Backstory

This is a pretty long script and complicated to explain so I'll try and keep it short. Basically I have this quest system that when the player clicks a NPC I receive a quest about going to killed another NPC along with direction on where to go.

Problem

My problem is that I don't know how I could possibly tell the game that

1: I've Killed the NPC and now I'm ready for my reward

2:This isn't the first time I've talked to you so don't repeat the dialog of giving me the quest

So basically I'm trying to make it so that when I've finished the quest the game knows I've finished it and it doesn't give me the dialog. I've tried many ways to do this but they've all haven't worked. For example I've tried using debounces to tell the game that yes I've done 1 and 2, but they've all haven't worked. If you could help me that would be very much appreciated. :)

Local Script in StarterGui

local Player = game.Players.LocalPlayer
repeat wait() until Player.Character
local char = Player.Character
local hum = char.Humanoid
local root = char:WaitForChild("HumanoidRootPart")
local Torso = char:WaitForChild("Torso")
local PTorso = game.Workspace.Pirate:WaitForChild("Torso")
local Mouse = Player:GetMouse()
local ft = true


PTorso.Click.MouseClick:Connect(function()
    if not ft then return end
    ft = false
    local SG = Instance.new("ScreenGui")
    SG.Parent = script.Parent
    local Frame = Instance.new("Frame")
    Frame.Parent = SG
    Frame.Name = "PirateTextFrame"
    Frame.Position = UDim2.new(0.315, 0,0.597, 0)
    Frame.Size = UDim2.new(0, 602,0, 131)
    Frame.Visible = true
    Frame.BackgroundColor3 = Color3.new(0,255,127)
    Frame.BackgroundTransparency = 0.65
    Frame.BorderSizePixel = 0
    local TL = Instance.new("TextLabel")
    TL.Parent = SG
    TL.Name = "PirateTextLabel"
    TL.BackgroundColor3 = Color3.new(0,255,255)
        TL.Position = UDim2.new(0.32, 0,0.597, 0)
    TL.Size = UDim2.new(0, 595,0, 125)
    TL.BorderSizePixel = 0
    TL.BackgroundTransparency = 0
    TL.TextScaled = false
    TL.TextSize = 14
    TL.TextWrapped = true
    local Text = "ARRR Mate! from tha looks of it yar mus be a travller! Tell ya what, if you can kill that zombie I'll give ya plenty of gold. What'da say?"
    for i = 1,#Text do
        TL.Text = string.sub(Text, 1, i)
        local Click = Instance.new("Sound")
        Click.Parent = Torso
        local Sounds = {"rbxassetid://537744814","rbxassetid://140910211","rbxassetid://421058925"}
        Click.SoundId = Sounds[math.random(#Sounds)]
        Click:Play()
            wait()
    end

for i = 1,#Text do
Torso:FindFirstChild("Sound"):Destroy()
end
    local Yes = Instance.new("TextButton")
    Yes.Parent = SG
    Yes.Name = "PirateTextLabel"
Yes.Text = "Ok, Where's the zombie?"
    Yes.BackgroundColor3 = Color3.new(0,255,255)
        Yes.Position = UDim2.new(0.8, 0,0.596, 0)
    Yes.Size = UDim2.new(0, 112,0, 40)
    Yes.BorderSizePixel = 0
    Yes.BackgroundTransparency = 0
   Yes.TextScaled = false
    Yes.TextSize = 8
    Yes.TextWrapped = true
Yes.MouseButton1Down:Connect(function()
    local Text = "Thanks alot ol'chum. There Zombie is Right to yer right."
    Yes:Destroy()
    for i = 1,#Text do
        TL.Text = string.sub(Text, 1, i)
        local Click = Instance.new("Sound")
        Click.Parent = Torso
        local Sounds = {"rbxassetid://537744814","rbxassetid://140910211","rbxassetid://421058925"}
        Click.SoundId = Sounds[math.random(#Sounds)]
        Click:Play()
            wait()
    end
    -------------------------------------------THE CODE BELOW IS THE MOST IMPORTANT TO SOLVING THIS QUESTION--
        local Yes2 = Instance.new("TextButton")
    Yes2.Parent = SG
    Yes2.Name = "PirateTextLabel"
Yes2.Text = "..."
    Yes2.BackgroundColor3 = Color3.new(0,255,255)
        Yes2.Position = UDim2.new(0.8, 0,0.596, 0)
    Yes2.Size = UDim2.new(0, 112,0, 40)
    Yes2.BorderSizePixel = 0
    Yes2.BackgroundTransparency = 0
   Yes2.TextScaled = false
    Yes2.TextSize = 14
    Yes2.TextWrapped = true
Yes2.MouseButton1Down:Connect(function()
    SG:Destroy()
 fr = true   
end)
end)
end)

while fr do
    if not fr then return end
        workspace.Zombie:WaitForChild("Humanoid").Died:Connect(function()
    local creator = workspace.Zombie:WaitForChild("Humanoid"):FindFirstChild("creator")
    if creator ~= nil then
        local me = creator.Value
print("killed something")
local fr = true  
end
        end)
        end



Regards, Bl_ueHistory

0
maybe try putting the "workspace.Zombie:WaitForChild("Humanoid").Died" outside of the while loop Leamir 3138 — 5y
0
I suggest adding a folder to a player when they join the game that contains bool values. Name the folder "QuestCompletions" and the boolValues can be named after every quest in the game. Set the value to true when they complete it and use that as an indicator. That would make it DataStore compatible so you wouldn't have to do the quest every time you join. cmgtotalyawesome 1418 — 5y

Answer this question