I am trying to make a script where if a player says a certain word they will get a tool. For example, if a player says sword, they will get a sword in their backpack. This is what I have so far.
local tools = game.Lighting.Sword local tool = game.Lighting.Bow local input = script.Parent.TextBox local output = script.Parent.TextLabel local function raw_input(prompt) local text = "" output.Text = prompt input:CaptureFocus() local event = input.FocusLost:connect(function(enterPressed) if enterPressed and input.Text ~= "" then text = input.Text else input:CaptureFocus() end end) repeat wait() until text ~= "" return text end -------------------------------------------------Dialogue--------------------------- local response = raw_input("What is your name?") output.Text = "Hello, " .. response .. "!" repeat wait(2) until text ~= "" response = raw_input("Would you like to go on a quest?") output.Text = "" .. response .. "? You didn't have a choice. It was always going to be yes." wait(3) response = raw_input("You will need a weapon. Would you like a bow or sword?") if input.Text == "bow" or input.Text == "sword" or input.Text == "Sword" or input.Text == "Bow" then output.Text = "Great choice! I knew you would pick the " .. response .. "!" else response = raw_input("What? What is a " .. response .. "? Please pick a sword or bow.") output.Text = "Great choice! I knew you would pick the " .. response .. "!" end if input.Text == "sword" or input.Text == "Sword" then tools:Clone().Parent = player.Backpack end if input.Text == "Bow" or input.Text == "bow" then tool:Clone().Parent = player.Backpack end
I made some fixes :) and it will work PS You can use lighting service. ServerStorage will not work probably ( it will not work if you have got FilteringEnabled ( game.Workspace ) ) ReplicatedStorage is using to use things first.
local tools = game.Lighting local input = script.Parent.TextBox local output = script.Parent.TextLabel local player = game.Players.LocalPlayer local function raw_input(prompt) local text = "" output.Text = prompt input:CaptureFocus() local event = input.FocusLost:connect(function(enterPressed) if enterPressed and input.Text ~= "" then text = input.Text else input:CaptureFocus() end end) repeat wait() until text ~= "" input.Text = "" return text end -------------------------------------------------Dialogue--------------------------- local response = raw_input("What is your name?") output.Text = "Hello, " .. response .. "!" wait(2) response = raw_input("Would you like to go on a quest?") output.Text = "" .. response .. "? You didn't have a choice. It was always going to be yes." wait(2) response = raw_input("You will need a weapon. Would you like a bow or sword?") if string.upper(response) == "BOW" then output.Text = "Great choice! I knew you would pick the bow!" tools.Bow:Clone().Parent = player.Backpack elseif string.upper(response) == "SWORD" then output.Text = "Great choice! I knew you would pick the sword!" tools.Sword:Clone().Parent = player.Backpack else while true do response = raw_input("What? What is a " .. response .. "? Please pick a sword or bow.") if string.upper(response) == "BOW" then output.Text = "Great choice! I knew you would pick the bow!" tools.Bow:Clone().Parent = player.Backpack break elseif string.upper(response) == "SWORD" then output.Text = "Great choice! I knew you would pick the sword!" tools.Sword:Clone().Parent = player.Backpack break end end end