Client Pushbox Issues

So I’ve been working on a Finding Game which has been BLOWING UP! I’ve been trying to get client pushboxes to work, but the issue is, the pusboxes duplicate when another player joins or the pushboxes can be pushed by other players.

Any help would be appreciateed!

My script (In StarterCharacterScripts)

for i, pushbox in pairs(game.Workspace.PushBoxes:GetChildren()) do
	
	pushbox:Destroy()
	
end

for i, pushbox in pairs(game.ReplicatedStorage.PushBoxes:GetChildren()) do

	local box = pushbox:Clone()
	box.Parent = workspace.PushBoxes

end

Edit 1 : Sometimes it works, sometimes it doesn’t. (Almost always the latter.)

If you want the pushbox entirely ClientSided, why not create the pushbox with a local script only once? Depends on how your game works, I guess.

Anyhow, to prevent players from pushing the PushBox, you should use collision groups. I did this before by creating a collision group for each player’s character and a collision group for the pushbox, and from then made it so the collision group the pushbox was in couldn’t collide with any characters other than the local player’s character.

That sounds pretty confusing. Mind giving me a script example?

I’ll try to explain this better:
If you don’t understand CollisionGroups, I recommend first checking out the documentation here.
Roblox does a pretty fine job explaining it.

Since we don’t want your client-sided pushbox to collide with anyone who isn’t the local player, I am suggesting creating a collision group for your pushbox. Then, continuing to utilize collision groups, make it so the collision group of the pushboxes can’t collide with other players. You can do this by creating an individual collision group for each player’s character, and go through and set the collision between the pushbox’s collision group and that player’s character’s collision group to not collide.

Here’s a script example of setting up the collision groups:

local physicsService = game:GetService("PhysicsService")

game.Players.PlayerAdded:Connect(function(player)
     physicsService:CreateCollisionGroup(player.Name.."'s CharacterCollisionGroup")
     physicsService:CreateCollisionGroup(player.Name.."'s Pushboxes")

     for i,v in pairs(game.Players:GetPlayers()) do 
          if v ~= player then 
               physicsService:CollisionGroupSetCollidable(v.Name.."'s CharacterCollisionGroup", player.Name.."'s Pushboxes", false)
          end
     end
end)

This code sample is only to get the point across: nothing is actually being added to the collision groups in this example, as well as it is not taking into consideration players who joined afterward. I’ll leave that up to you to accomplish.

Thank you, I’ll try my best to do that. If I have any issues, I’ll provide my current script.

There’s one thing I wanna say.

AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA THIS IS HURTING MY HEADDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD

1 Like