The script works by detecting when somebody says a specific phrase, then copies a tool from ReplicatedStorage and places it in the player's backpack.
I'm trying to make a variation of it where the commands only apply to a few specific players and identifies them by their usernames. I'm unsure how that would be rigged, though. Here's a basic version of the script. I keep the tools stored in a folder called "Tools" in Replicated Storage. You can just remove ".Tools" from the script and keep them in Replicated Storage to make it easier to test, though.
I'm thinking that it should be like "if player.name = {"examplename", "examplename2",} then..." and then only gives them permission to use that command. But when I tried it on my own, it didn't work out. I'm still a novice at scripting. Below is a vanilla version of the script so it's easier for you guys to work with.
Thanks in advance to whoever knows how to solve this!
game.Players.PlayerAdded:connect(function(player) -- gets player
player.CharacterAdded:connect(function(Character)
--I think about here would be where permissions would be inserted. I don't know how to rig that, though.
player.Chatted:connect(function(msg)
local speaker = player
print(speaker)
if msg == '/knight' then
local knight1 = game.ReplicatedStorage.Tools:FindFirstChild("Sword")
local knight2 = game.ReplicatedStorage.Tools:FindFirstChild("Shield")
local knight3 = game.ReplicatedStorage.Tools:FindFirstChild("Spear")
knight1:Clone().Parent = speaker.Backpack
knight2:Clone().Parent = speaker.Backpack
knight3:Clone().Parent = speaker.Backpack
elseif msg == "/archer" then
local archer1 = game.ReplicatedStorage.Tools:FindFirstChild("Arrow")
local archer2 = game.ReplicatedStorage.Tools:FindFirstChild("Dagger")
local archer3 = game.ReplicatedStorage.Tools:FindFirstChild("Darts")
archer1:Clone().Parent = speaker.Backpack
archer2:Clone().Parent = speaker.Backpack
archer3:Clone().Parent = speaker.Backpack
end
end)
end)
end)
