Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

How i can remove collide from Head?

Asked by
174gb 290 Moderation Voter
4 years ago

I'm trying remove collision of my head to look same this: GIF

Current script

local Players = game:GetService('Players')
local PS = game:GetService('PhysicsService')
local PlayerGroup = PS:CreateCollisionGroup('Player')
PS:CollisionGroupSetCollidable('Player','Player',false)

function NoCollide(Character)
    for i,v in next, Character:GetChildren() do
      if v:IsA("BasePart") and v.Name == 'Head' then
           PS:SetPartCollisionGroup(v,'Player')
        end
    end
end

Players.PlayerAdded:Connect(function(plr)
   plr.CharacterAdded:Connect(function(chr)
       NoCollide(chr)
    end)
end)

I got no errors

0
Try to take away in line 8 the v:IsA("BasePart") because usually the classname of a head is a Part CoolMcroy 35 — 4y
0
not working yet 174gb 290 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Well, first, the Head is actually a Part and not a BasePart. Second, I would go for the route of printing to see where the error is, because with stuff like :IsA("???") as long as what's in the quotes exists as something ROBLOX has, it's not going to give an error; it's kind of like how :FindFirstChild("???") won't give an error. Third instead of doing the whole CollisionGroupSetCollidable, I would just set v.CanCollide to false. Fourth, next is somewhat deprecated, so just use pairs instead. Here's what I did to fix your code, tell me if it helped:)

local Players = game:GetService('Players')

function NoCollide(Character)

    for i,v in pairs(Character:GetChildren()) do
      if v:IsA("Part") and v.Name == 'Head' then

        v.CanCollide = false
    else
        v.CanCollide = true
        end
    end
end

Players.PlayerAdded:Connect(function(plr)
   plr.CharacterAdded:Connect(function(chr)
       NoCollide(chr)
    end)
end)

0
Roblox forces collide property remain in 'true' and Basepart is a primitive class of mesh, part, union .. that is, everything that is rendered and has physics is a BasePart 174gb 290 — 4y
Ad

Answer this question