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

How to make a msg giver script?

Asked by 10 years ago

I want like to know how to make the text msg giver script I tried to made one which is here:

game.Players.TicTocHat.Chatted:connect(function(msg) if msg == "bb" then game.Lighting:FindFirstChild("Pass/Shoot"):Clone().Parent = game.Players.LocalPlayer.Backpack end end)

but it didn't work and also I would like to know so that everyone can say "bb" and get a tool not just me.

1 answer

Log in to vote
0
Answered by 10 years ago

You could use the PlayerAdded event, and also use the if coding so that the script doesn't error;

local function Chat(plr,msg) --Heres our Chat function

if msg:lower() == "bb" then --If the Player types 'bb then
if game:FindFirstChild("Lighting") and game.Lighting:FindFirstChild("Pass/Shoot") and plr and plr:FindFirstChild("Backpack") then --This will check to see if Lighting, Pass/Shoot, The Player, and the Player's Backpack are existant
local GiveTool = game.Lighting["Pass/Shoot"]:Clone() --This will clone the object
GiveTool.Parent = plr.Backpack --This will Parent the Cloned object into the Player's Backpack
end --This ends the code for the second 'if' statement
end --This ends the code for the first 'if' statement

end --This ends the code for the 'Chat' function

game.Players.PlayerAdded:connect(function(plr) --Heres the PlayerAdded event; This will fire everytime a Player joins; The Player whom has joined will be identified as 'plr'
plr.Chatted:connect(function(msg) Chat(plr,msg) end) --This connects the Player's Chat to the 'Chat' function
end) --This ends the code for the 'PlayerAdded' event

Hope this helped!

0
Thank you so much TheAlphaStigma! TicTocHat 6 — 10y
0
No problem man. :) I've been working on Admin Commands for along time, so thanks to all that time, I was able to help you with your question. :) TheeDeathCaster 2368 — 10y
Ad

Answer this question