Hi. I’m making a game, and now I want to make a script that will teleport you to a player or bring him, but I don’t know how to disable collision while player being teleported. It will also be helpful in preventing players from flinging everyone with exploits. Thanks!
You can use collision groups.
local physicsService = game:GetService("PhysicsService")
physicsService:RegisterCollisionGroup("Player")
physicsService:CollisionGroupSetCollidable("Player", "Player", false)
function assignPlayerCollisionGroup(char)
char:WaitForChild("HumanoidRootPart")
char:WaitForChild("Head")
char:WaitForChild("Humanoid")
for _, v in char:GetDescendants() do
if v:IsA("BasePart") then
v.CollisionGroup = "Player"
end
end
end
game.Players.PlayerAdded:Connect(function(plr)
plr.CharacterAppearanceLoaded:Connect(function(char)
assignPlayerCollisionGroup(char)
end)
end)
Alright, but is there an easier script?
No, to my knowledge the script provided should indeed work.
Nope, I’m asking if there’s an easier example of the script, like less lines of code and etc.
the script that they provided is pretty basic. They do everything required to disable player collision and in a pretty safe way as well.
Here’s a short breakdown of what the code does
- Create the collision group.
- Set the group to not collide with the same group
- Create a function for giving every part in the character the player collision group after every crucial character part has loaded
- Connect to a signal to use that function when a players character has loaded
I understand what the script’s doing, but isn’t there an easier example of the script without creating collision groups and etc?
no, unless you want an extremely poorly optimized script. The best, easiest and most optimized way of doing this is with collision groups and is also one of the things they’re intended for
I know, I answered the question with “no” then provided why.
This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.