So basically I have this script where it makes players able to walk through parts and stuff. However this is inconvenient because the game i'm making is a sort of obby course and if players can just walk through all the walls it would be too simple. My scripting knowledge is still rather basic so I have no idea how to do this, but I was wondering if anyone has a way of making it so that players can only walk through each other and still collide on things like parts. This is the code I have at the moment:
local player = game.Players.LocalPlayer function Touched(hit) if hit.Locked == false then hit.CanCollide = false end end function TouchEnded(hit) if hit.Locked == false then hit.CanCollide = true end end player.CharacterAdded:connect(function(character) character.Head.Touched:connect(Touched) character.Head.TouchEnded:connect(TouchEnded) character.Torso.Touched:connect(Touched) character.Torso.TouchEnded:connect(TouchEnded) character["Left arm"].Touched:connect(Touched) character["Left arm"].TouchEnded:connect(TouchEnded) character["Right arm"].Touched:connect(Touched) character["Right arm"].TouchEnded:connect(TouchEnded) character["Left leg"].Touched:connect(Touched) character["Left leg"].TouchEnded:connect(TouchEnded) character["Right leg"].Touched:connect(Touched) character["Right leg"].TouchEnded:connect(TouchEnded) end)
^ I put that in a Local Script and placed it inside StarterPack, which worked. It's just that I need it to allow players to walk through each other and not through parts (because the obby i'm making is extremely challenging and it would suck if players could affect the progress of others by blocking paths off etc)
Thanks for any help/advice
~ MrTurkeys
Your best bet is probably to set CanCollide = false
on all of the players' parts whenever they collide and use a BodyForce to keep them from falling through the map.
To set your torso and head's CanCollide
to False
, you need to make a loop.
I do not feel like making the script for you since it wouldn't really be helping you, it would be doing the whole job for you, but for the cancollide script, use this:
game:GetService("RunService").stepped:connect(function() game.Players.LocalPlayer.Character.Torso.CanCollide=false game.Players.LocalPlayer.Character.Head.CanCollide=false end)