Hello, developers!
So I was making a script as to when a player who is ranked 10 or above in a group says "!handto (player username) all their items go into the backpack of the player they specified to hand it to.
However, my script is not working and nothing is displayed in the output???
Can someone aid me or provide me with some sort of reference or help? I can’t seem to find anything.
Thank you,
bulder251
Here is the code for reference:
local GroupId = 10421757
local MinimumRankToUseCommand = 10
local Player = game.Players.LocalPlayer
game.Players.PlayerAdded:Connect(function(Player)
if Player:GetRankInGroup(GroupId) >= MinimumRankToUseCommand then
Player.Chatted:Connect(function(Message)
local Words = string.split(Message, " ")
if Words[1] == "!handto" then
local NameOfPlayerToTakeItem = Words[2]
local PlayerToHand = game.Players:FindFirstChild(NameOfPlayerToTakeItem)
if PlayerToHand then
game.ReplicatedStorage.GivePlayerItem.OnServerEvent:Connect(function(Player, PlayerName)
local ToolToGive = Player.Character:FindFirstChildWhichIsA("Backpack")
ToolToGive.Parent = game.Players[PlayerName].Backpack
end)
end
end
end)
end
end)