Local part affecting other players

I have a local script that creates a moving local part in starter gui, however, the moving part for some reason is somehow affected by other players but only in a specific situation. I also tried putting the script into starter player and character scripts but that didn’t work either.
This is my code.

Capture

The situation where the part is affected by other players is when the part is moving up and down and 2 players are bot on it, even though they are both local parts the players both affect each other’s parts.

Is the part parented to the player?

The part is parented to the workspace is that the issue? Also sorry I’m a beginner.

Can you give an example of such a situation?

Well basically when 2 players are bot on a moving part at the same area when the player collides with the other player’s local moving part, it starts to jitter a bit eventually leading to the player falling off.

Don’t know if it’s intentional but in the player removing event you just destroy the part, meaning whenever any player leaves the game (not just the local player) all parts will be destroyed

It’s more of if anyone leaves the parts will be destroyed.

@ZeInventor if you want it to remove it when the player leaves, there’s no need since everything on the client will be deleted anyway, so you can just remove that “PlayerRemoving” entirely.

I thought that only the local part would be destroyed if I did that.

If you change it to this then it should only destroy that part, but I don’t think this is related to your issue

players.PlayerRemoving:Connect(function(player)
    if player == players.LocalPlayer then part:Destroy() end
end)
1 Like

Good point aswell


Thanks, I’ll fix that as well but does anyone know how to fix the other issue?

Does the Player A jitter and fall off on the Player B’s screen or Player A’s screen?

It’s random whichever one is affected but it’s not the player that jitters, the part jitters causing the player to fall off.

But the player that doesn’t see the part doesn’t fall off?

If Player A can’t see the part, does he still fall off anyway?

One of the players falls off but neither of them see the other players part, they only see their own, also I don’t think this issue has to do with the situation, I think it has to do with the making of the part itself, of course I could be wrong.

Here’s what I have done in my obby game that has parts that move on the client.

I used PhysicsService in my code and I made Collision Groups without code.
Here’s what each Collision Group was used for in my game:

  • Default (anything that did not move, Parts are in this group by default)
  • ClientParts (any moving part made on the client)
  • ClientPlayer (contains all the parts of the client’s character)
  • Players (contains all the parts of all other player’s characters)


image

Also, the checkboxes are very important here. They are what causes parts to ignore other parts and pass through them or actually collide with them. A check means the parts in both collision groups will collide with each other.

I had the server place all of a player’s characters into the “Players” collision group when they spawn using the CharacterAdded event. I did this by looping through their character’s model and putting any BasePart into the Collision Group with PhysicsService:SetPartCollisionGroup([BASEPART_HERE], “Player”)

Then the client would place all of their character’s parts into the “ClientPlayer” collision group. I did this by looping through their character’s model and putting any BasePart into the Collision Group with PhysicsService:SetPartCollisionGroup([BASEPART_HERE], “ClientPlayer”)

Also you need to place any client-sided part into the “ClientParts” collision group.

Extra Partially Related Notes:
All BodyMovers have newer replacements that Roblox recommends you use instead.

Also, you do not have to destroy client-sided parts when the player leaves. That’s just silly because the entire client basically gets deleted when they leave because that person’s computer is no longer running your Roblox game.

1 Like

Thanks for the response, but does this mean there’s no way to fix this issue other than disabling collisions for the parts?

Do not touch CanCollide if that is what you mean by “disabling collisions for the parts”. This is Collision Groups, they are different from outright disabling collisions. For clarification, I am not telling you to never disable CanCollide, it’s just not needed for this situation.

But, yes, if you do not want other players to interfere with a client’s client-created parts, then you have to make it so the other players’ characters pass through those parts, and Collision Groups are a great way to do that.

1 Like