I'm trying to make a giver that will give you coffee if you type "coffee" or "Coffee" into the textbox and hit enter, but the script just isn't working. I took the script out of a custom giver and changed a few things, could someone please help?
I am a noob with scripting, so please go easy on me!
--[[----------------]]-- local A = script.Parent.TextBox --[[----------------]]-- if A.text == "Coffee" or A.text == 'coffee' then local allow_duplicates = true local allow_team ={ } --[[----------------]]-- local button = script.Parent local startcolor = button.BrickColor local DB = false local toolfolder = button.Parent["ToolFolder"] local toolstorage = {} for i, tool in pairs(toolfolder:GetChildren()) do table.insert(toolstorage, tool:clone()) end toolfolder:Destroy() local block = button.Parent:FindFirstChild("Block") if block ~= nil then if block:FindFirstChild("") then if block.NameDisplay.TextLabel.Text == "" then if #toolstorage > 0 then block.NameDisplay.TextLabel.Text = toolstorage[1].Name else block.NameDisplay.TextLabel.Text = "" end end end end button.Touched:connect(function(hit) if DB then return end if hit == nil then return end if hit.Parent == nil then return end local player = game.Players:GetPlayerFromCharacter(hit.Parent) if player ~= nil then if player:FindFirstChild("Backpack") then local allow = true if #allow_team > 0 then local teams = game:GetService("Teams"):GetChildren() if #teams > 0 then allow = true for i, team in pairs(teams) do for i, allowedteamname in pairs(allow_team) do if team.Name == allowedteamname then if player.TeamColor == team.TeamColor then allow = true end end end end end end if not allow_duplicates then for i, tool in pairs(toolstorage) do if player.Backpack:FindFirstChild(tool.Name) then allow = false end end end if allow then DB = true button.BrickColor = BrickColor.new("White") for i, tool in pairs(toolstorage) do local newtool = tool:clone() newtool.Parent = player.Backpack end wait(2) button.BrickColor = startcolor DB = false end end end end) --[[----------------]]-- wait(5) script.Parent.Parent.Visible = false
local ss = game.ServerStorage -- make sure to put the coffee tool in serverstorage and name it "coffee" or "Coffee" but then you need to edit the script. player = game.Players.LocalPlayer
function onChatted(msg)
if string.find(string.lower(msg), string.lower("coffee")) and string.find(string.lower(msg), string.lower("")) then
if not player.Backpack:FindFirstChild("coffee") then
local coffee = ss:FindFirstChild("coffee"):Clone() coffee.Parent = player.Backpack end end end
game.Players.PlayerAdded:connect(function(OnChatted)
end
end) -- I personally didn't test it but it should work.