Turning off collisions for a character's head

First off, I need a way to immediately turn the CanCollide for a character’s head on since the characters’ heads CanCollide are always automatically set to false.

Second off, I read a devforum post saying that when they tried to do this, the character’s head kept on setting itself’s CanCollide to off.

So I need help either creating a script that can turn off collisions for a character’s head or create a script that creates a new object that is welded to the character’s head that is invisible but has CanCollide on (which is a worse way but a solution nonetheless).

What happens: What happens

What I want to happen: What I want to happen

Code (designed for creating a new object to weld to a head):

local Players = game:GetService('Players')
function headcollision(player)
    local headreplacement = Instance.new("Part")
    headreplacement.Size = Vector3.new(2,1,1)
    headreplacement.Transparency = 1
    headreplacement.CanCollide = true
    headreplacement.Parent = player.Character
    local weld = Instance.new("Weld")
    weld.Part0 = headreplacement
    weld.Part1 = player.character.Head
end
Players.PlayerAdded:Connect(headcollision)

Error:
ServerScriptService.Script:11: attempt to index nil with 'Head'

replace the last line with this and tell me if the script works

Players.PlayerAdded:Connect(function(plr)
	plr.CharacterAppearanceLoaded:Connect(wait)
	headcollision()
end)

There is a new error.
ServerScriptService.Script:7: attempt to index nil with 'Character'

Ok then, replace the first line with this

local Players = game:GetService('Players')
local player = Players.LocalPlayer

Still the same error.
ServerScriptService.Script:8: attempt to index nil with 'Character'

Finded a error: you didnt put the weld parent, replace the line 8 with this

    local weld = Instance.new("Weld", workspace) -- Change workspace to the Weld Parent (Optional)

and the same thing but with line 3

Wait, i didnt see the (Function(player) lemme fix the script for you.

Okay, here’s the updated version right now just in case I got something wrong.

local Players = game:GetService('Players')

local player = Players.LocalPlayer

function headcollision(player, workspace)

local headreplacement = Instance.new("Part")

headreplacement.Size = Vector3.new(2,1,1)

headreplacement.Transparency = 0

headreplacement.CanCollide = true

headreplacement.Parent = player.Character

local weld = Instance.new("Weld", workspace)

weld.Part0 = headreplacement

weld.Part1 = player.Character.Head

end

Players.PlayerAdded:Connect(function(plr)

plr.CharacterAppearanceLoaded:Connect(wait)

headcollision()

end)
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAppearanceLoaded:Connect(wait)
	
	local headreplacement = Instance.new("Part", workspace)
	
	headreplacement.Size = Vector3.new(2,1,1)
	headreplacement.Transparency = 0
	headreplacement.CanCollide = true
	headreplacement.Parent = player.Character

	local weld = Instance.new("Weld", headreplacement)

	weld.Part0 = headreplacement
	weld.Part1 = player.Character.Head
	
end)

has to be

player.Character

“C” of “character” has to be upper case

1 Like

Thanks, I still got an error though.

New error:
ServerScriptService.Script:14: attempt to index nil with 'Head'
I think I just have to use WaitForChild()

Then you will need to do what others said, waiting for the character to be spawned.

Yea, I used the fixed script from @Misinformater but it still gave the error.

I already tried with WaitForChild(“Head”) idk bro thats not normal

Kinda skipping all of the replies, but here’s something I whipped up quickly (essentially the same thing though):

local head = script.Parent:WaitForChild('Head'):Clone()
head:ClearAllChildren()
head.Transparency = 1
head.CanCollide = true
head.Parent = script.Parent.Head
local weld = Instance.new('Weld',head)
weld.Part0 = head
weld.Part1 = head.Parent

Just put that in a server script it StarterCharacterScripts.

2 Likes

Thank you so much! I’ve been trying to figure it out for so long.

You’re welcome. I had no idea that head collision was even removed. Though personally, I prefer to remove player collision all together to avoid fling/void exploits.