I don’t really have an idea on how to find people when in Chat. for example:
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
(Maybe it would be if playermatches leaderboard. I don’t know, I have no idea)
But what I’m trying to do is make a Admin Command Any help would be great!
I would suggest using HDAdmin commands and learning the API. You can find that here. You’ll learn a lot and become and good programmer. Now, to actually do this, you’ll need to simply delete the head part from the character. This can be done as follows:
local playerToBehead = somePlayer
local character = playerToBehead.Character
local head = character:FindFirstChild("Head")
head:FindFirstChild("NeckWeld"):Destroy()
game.Players.PlayerAdded:Connect(function(plr)
plr.Chatted:Connect(function(msg)
local message = string.sub(msg, 1, 9)
if message == ":Behead " then return end
local player_name = string.sub(msg, 9, #msg)
print(player_name)
assert(game.Players:FindFirstChild(player_name))
local player = game.Players:FindFirstChild(player_name)
local char = player.Character or player.CharacterAdded:Wait()
char.Head:Destroy()
end)
end)
Updated it, and tested, it works!
This removes the command from the text, then references the player’s name.
local beheadCommand = "/behead"
game.Players.PlayerAdded:Connect(function(player)
player.Chatted:Connect(function(msg)
if message:sub(1, beheadCommand:len()):lower() == beheadCommand then
local char = player.Character
local head = character:FindFirstChild("Head")
head:FindFirstChild("NeckWeld"):Destroy()
end
end)
end)
Something like this would probably work (untested).