Press a button to were Headless

You can write your topic however you want, but you need to answer these questions:

  1. What do you want to achieve? I want to press a GUI-Button to were headless, then agein to were my old head

  2. What is the issue? The script do not work and do not show any error

  3. What solutions have you tried so far? I tried to change between local and normal script (now its a script) and i tried to change the “head local”

After that, you should include more details if you have any. Try to make your topic as descriptive as possible, so that it’s easier for people to help you!

local RemoveHead = script.Parent

local Head = game.Players.LocalPlayer.Character.Head.MeshId

local Headless = game.ReplicatedStorage.Headless.Value


game.ReplicatedStorage.CurrentHead.Value = Head 



RemoveHead.MouseButton1Click:Connect(function()
	
	if Head == Headless then
		Head = game.ReplicatedStorage.CurrentHead.Value
	else
		Head = Headless
	end
end)

I am a beginer scripter and want to learn. now i want to change the body part to make my game open for more.

1 Like

You cannot assign MeshId, instead you can clone the headless, use a SpecialMesh or set Head and face Transparency to 1.

1 Like

If you want other players to be able to see the player wearing headless you’ll need to fire a remote event (You can learn more about Remote Events and Remote Function here)

You can change the transparency of their head and face with a simple script like this

local PlayerHead = workspace:FindFirstChild(player.Name):FindFirstChild("Head")	
PlayerHead.Transparency = 1
if PlayerHead:FindFirstChild("face") then
	PlayerHead:FindFirstChild("face").Transparency = 1
end

Hope this helps. :yum:

So many bad practices… Some of these are as follows:

  • Not using :GetService() for services
  • Writing .Value in your variables, etc.
local RemoveHead = script.Parent

local Head = game:GetService("Players").LocalPlayer.Character.Head

local Headless = game:GetService("ReplicatedStorage").Headless

game:GetService("ReplicatedStorage").CurrentHead.Value = Head.Value

RemoveHead.MouseButton1Click:Connect(function()
	if Head.MeshId == Headless.Value then
		Head.MeshId = game:GetService("ReplicatedStorage").CurrentHead.Value
	else
		Head.MeshId = Headless.Value
	end
end)

Edit:
I just realized that you can’t change the head meshid as it is restricted, you should do what @7zn_y said and set the transparency of the head and face to 1

1 Like

I have no idea… im a poor scripter and i spen the last 1.5 hour trying to figgure this out by useing the scripts abov and youtube. I have no ide how more then the very basics work and i dident even find a totorial.

Ye, idk i tried eveerything but i still dont get it. i get no errors and i dont know how to find out whats wrong for me it looks right but probobly isent so i got no clue…

You can use a HumanoidDescription to seamlessly integrate different outfits to your players.

There’s a lot of code here, but i’ll try to follow up with any questions you have. But pretty much consider “HumanoidDescriptions” as ways of describing how a character should look. We use the Humanoid to actually apply the HumanoidDescriptions.

I’ve decided to go with two HumanDescriptions, one description that describes how the player looks when they first join the game, and then another one that describes how they should look with the headless outfit applied to them. I stored both of these values in ServerStorage. Once the players are removed, the descriptions in ServerStorage will also be removed to avoid clutter.

In a Script in ServerScriptService:

local Players = game:GetService("Players")
local ServerStorage = game:GetService("ServerStorage")

local HEADLESS_HEAD_ID = 134082579

game:GetService("ReplicatedStorage").ApplyCharacterDescription.OnServerEvent:Connect(function(PlayerRequestingDescription, RequestedDescription)
	
	if RequestedDescription == "Headless" then 
		local Description = ServerStorage:FindFirstChild("Headless_" .. PlayerRequestingDescription.UserId)
		if Description then 
			PlayerRequestingDescription.Character.Humanoid:ApplyDescription(Description)
		end
	elseif RequestedDescription == "Normal" then 
		local Description = ServerStorage:FindFirstChild("Normal_" .. PlayerRequestingDescription.UserId)
		if Description then 
			PlayerRequestingDescription.Character.Humanoid:ApplyDescription(Description)
		end
	end
end)

Players.PlayerAdded:Connect(function(PlayerThatJoined)
	PlayerThatJoined.CharacterAdded:Connect(function(CharacterThatJoined)
		local NormalDescription = CharacterThatJoined.Humanoid:GetAppliedDescription()
		NormalDescription.Name = "Normal_"..PlayerThatJoined.UserId
		NormalDescription.Parent = ServerStorage
		
		local HeadlessDescription = CharacterThatJoined.Humanoid:GetAppliedDescription()

		HeadlessDescription.Head = HEADLESS_HEAD_ID
		HeadlessDescription.Face = 0
		HeadlessDescription.Name = "Headless_"..PlayerThatJoined.UserId
		HeadlessDescription.Parent = ServerStorage
	end)
end)

Players.PlayerRemoving:Connect(function(PlayerBeingRemoved)
	local FoundDescriptionHeadless = ServerStorage:FindFirstChild("Headless_"..PlayerBeingRemoved.UserId)
	if FoundDescriptionHeadless then
		FoundDescriptionHeadless:Destroy()
	end
	
	local FoundDescriptionNormal = ServerStorage:FindFirstChild("Normal_"..PlayerBeingRemoved.UserId)
	if FoundDescriptionNormal then
		FoundDescriptionNormal:Destroy()
	end
end)

In a LocalScript under some button:

local ReplicatedStorage = game:GetService("ReplicatedStorage")

local Count = 0

script.Parent.MouseButton1Down:Connect(function()
	Count += 1
	if Count % 2 == 0 then 
		ReplicatedStorage.ApplyCharacterDescription:FireServer("Headless")
	else
		ReplicatedStorage.ApplyCharacterDescription:FireServer("Normal")
	end
end)

and a RemoteEvent in ReplicatedStorage.

The full hierarchy should look like this:
image

2 Likes

OOH god thanks this did in fact work. Im so greatfull!!!
Thanks for putting the time and effort to help me :smiley:

I tried to make it simple for them as they stated

I am a beginer scripter and want to learn.

and without completely removing the head, possibly breaking other scripts they have ingame, such as an overhead title gui. :yum:

Edit: Just realised that wasn’t a reply but a mention, thought you were mentioning my code, but still, while :GetService() is a better practice, they only wants basic lua for now it seems.

2 Likes