Need help with a headless script

So, I am having trouble with defining the head like.

local player = game:GetService(“Players”)
local humanoid = game:FindFirstChild(“Humanoid”)

player.Chatted:Connect(function(msg)
if msg == “/e headless” or “/e headless “ then
humanoid.Head.Transparency = 1
humanoid.Face:Destory()
humanoid.Decal:Destory()
end

I made this on mobile, tested it on studio but isn’t working, any problems?

3 Likes

You are using the .chatted event on the players service. Use the .PlayerChatted event.

1 Like

I think this is what your trying to do

local player = game:GetService("Players").LocalPlayer
local character = player.Character or player.CharacterAdded:Wait()

player.Chatted:Connect(function(msg)
	if msg == "/e headless" then
		character.Head.Transparency = 1
		character.Head.face:Destroy()
	end
end)
1 Like
local humanoid = game:FindFirstChild(“Humanoid”)

this won’t work because there is no child of the game with the name “Humanoid”.
you should try using the PlayerAdded on a server script to do this

First, you’re using “destory” instead of “destroy”

Also, you’re calling .chatted on the player service, not the player.

Also, you’re trying to find a child of the game that is a humanoid. The only things in the game are services.

You’re confusing the humanoid and the character. The humanoid is not the character, it is a child of the character. So you would need to do

humanoid.Parent.whatever

Hope this helped.

I don’t think this will work because it’s a local script, nobody else will see it but you

Yeah so, it would be a script but wouldn’t it break?

To make the script work for everyone in the server, you’d need to use @Rynappel’s code in a local script and use RemoteEvents to connect it to the server.

2 Likes

Try this in a server script

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		player.Chatted:Connect(function(msg)
			if msg == "/e headless" then
				print("Headless!")
				character.Head.Transparency = 1
				character.Head.face:Destroy()
			end
		end)
	end)
end)
2 Likes

If you want others too see you have a headless hra, then go ahead and use this code I’ve just written in short 3 minutes for you, can’t confirm if it works or not:

game.Players.PlayerAdded:Connect(function(player)
			player.CharacterAdded:Connect(function(chr)
				player.Chatted:Connect(function(msg)
					if msg == "/e headless" or "/e headless " then
					player.Character.Head.Transparency = 1
					player.Character.Head.face:Destroy()
              else 
print("Nope")
			end
		end)
	end)
end)
1 Like
game.Players.PlayerAdded:Connect(function(Player)
	Player.Chatted:Connect(function(msg)
		if msg:lower():sub(1, 11) == "/e headless" then
			local Character = Player.Character
			if Character then
				local Head = Character:FindFirstChild("Head")
				if Head then
					Head.Transparency = Head.Transparency == 1 and 0 or 1
					local Face = Head:FindFirstChild("face")
					if Face then
						Face.Transparency = Face.Transparency == 1 and 0 or 1
					end
				end
			end
		end
	end)
end)
1 Like

This script will make you headless if you say anything in chat… a simple if statement error

What are you talking about exactly?

you are doing if the message is “/e headless” or the string "/e headless " isnt nil then make the player headless

No, I’m doing if player chatted /e headless or /e headless then

but that is not what your script is doing.
try it out…

joinCommand = "/e headless" or "/e headless "

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(chr)
		player.Chatted:Connect(function(msg)
			if msg:sub(1, joinCommand:len()):lower() == joinCommand:lower() then
				-- == "/e headless" or "/e headless " then
				player.Character.Head.Transparency = 1
				player.Character.Head.face:Destroy()
			else 
				print("Nope")
			end
		end)
	end)
end)

Fixed.

i’m getting errors with this script,

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(chr)
		player.Chatted:Connect(function(msg)
			if msg == "/e headless" or "/e headless " then
				player.Character.Head.Transparency = 1
				player.Character.Head.face.Transparency = 1 -- it says "  face is not a valid member of Model "Workspace.vvKyee" "
			end
		end)
	end)
end)

Just use mine instead, it’s more reliable and has less irrelevant coding in it:

Command = "/e headless" or "/e headless "

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(chr)
		player.Chatted:Connect(function(msg)
			if msg:sub(1, Command:len()):lower() == Command:lower() then
				-- == "/e headless" or "/e headless " then
				player.Character.Head.Transparency = 1
				player.Character.Head.face:Destroy()
			else 
				print("Nope")
			end
		end)
	end)
end)
1 Like

if I type any other letter it goes back I think it’s because of the string.