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

3 comments
How would I go about doing that? Would I use an PlayerAdded function or something?
You could just connect the body force in the torso using the PlayerAdded event.
No, because you only want the BodyForce to be inside the Torso when the player's parts have CanCollide set to false. Use the Touched event on the HumanoidRootPart and connect it to a function that sets CanCollide to false on all of the player's parts and inserts a BodyForce into the Torso to counteract gravity.