I am looking to prevent the local player from being able to push around dummies just by walking into them. How can I do that?
You would have to use collision groups to configure which parts interact with eachother. This should give you a better understanding: BasePart | Documentation - Roblox Creator Hub
As said by @Prismatyx, you can use Collision Groups.
Here is a simple way you can do that:
Go to Models → Colission Groups
A window will pop-up like this:
Click Add Group and name it whatever (You can call it dummies) and press Enter:
Then create another group, (e.g. plrs) and press Enter:
On the side you’ll see some buttons (Default, StudioSelectable etc.), click the one you have made for the Dummies, and it should look like this:
So far so good!
Now to apply the collision groups to the dummies (you can create a script or do it like this:):
Select all the parts of the dummy in the Explorer.
On properties find/search for Collision Group:
Double click there and write the name you have given to the collision group earlier:
Lastly, to apply the collision group to each player that joins you can use the following script:
plrs = game:GetService("Players") -- Here you get the Players Server - all the players
ps = game:GetService("PhysicsService") -- Here you get the PhysicsService - you need this to apply the collision group.
plrs.PlayerAdded:Connect(function(plr) -- when a player joins
plr.CharacterAdded:Connect(function(chr) -- and their character has loaded
for key,value in pairs(chr:GetDescendants()) do -- get all the player's parts (like we did on the dummies)
if value:IsA("BasePart") then -- If it's a part (because there are some Scripts too!)
value.CollisionGroup = "plrs" -- Change the collisiongroup to plrs like we did on the dummies.
end
end
end)
end)
Hope I helped you!
I don’t want to remove the collision. I just want to prevent them from pushing each other. I was looking for something related to the weight.
I don’t want to remove the collision. I really only want to prevent the pushing around. Without touching the collision groups.
Pushing around means touching the Dummy. To prevent it from touching the dummy, you will need to change their collision groups so they don’t collide/push the enemies/dummies.
Changing collision will make the player able to pass through the dummy/enemy.
I want them to touch. I just dont want them to be pushed around. Like if I walk into the dummy or into another player. My body weight should influence the position of the enemy.
Maybe you can anchor the NPC’s HumanoidRootPart? That’s the closest thing to get what you want. They’ll touch, but it won’t do anything to the NPC. You could also use the collisiongroup idea from what others said and then use a constraint like vectorforce to do what you want when the NPC is touched, however that might be tricky and inefficient. Also isn’t pushing enemies and influeicning their position basically the same thing…?
Hmm… the closest thing I can think of is making the dummy move with the force being the mass of the player (but the mass cannot be edited, it’s a read-only variable )
script.Parent.Touched:Connect(function(hit)
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
if player then
local force = player.Character.HumanoidRootPart.Mass
local dummy = script.Parent.Parent
dummy.PrimaryPart.Position += Vector3.new(tonumber(force), tonumber(force), tonumber(force)) -- You can change that. atm it will make the dummy move on the X, Y, Z axis, with distance as the force (aka the player's mass).
end
end)
You can also check out this post which talks about the weight adjustment.
I actually forgot to mention my goal. I wanted to create a dashing system like strongest battlegrounds and I realized that when the user that is dashing. If they dash into an enemy the enemy isnt being moved around by the force of the velocity. so like that it’s easier for the dash punch to land an actual hit.