Need help with clientsided part spawning

  1. What do you want to achieve? Keep it simple and clear!
    I’m currently making a game where you push bricks into water and then you will get points / bits for it and I’m trying to make all the bricks client sided so the other players cannot steal the bricks.
  2. What is the issue? Include screenshots / videos if possible!
    My issue is other players being able to push another player’s block even though the block is client sided.
  3. What solutions have you tried so far? Did you look for solutions on the Developer Hub?
    I tried using :SetNetworkOwner but I noticed it is only accessible through the server.
    Video Example: https://streamable.com/gavcaq

Client Script:

		TotalSpawned += 1
		local SpawnLocation = SpawnLocations:GetChildren()[math.random(1, #SpawnLocations:GetChildren())]
		Brick.Parent = BrickDebris
		Brick.Name = ChosenBrick.Name

		if Brick:IsA("BasePart") then
			Brick.Position = SpawnLocation.Position + Vector3.new(math.random(1,3),math.random(1,3),math.random(1,3))
		end
		local function Touched()
			Brick.Touched:Connect(function(hit)
				if hit:GetAttribute("WaterMain") then
					RS.Remotes.SendBrick:FireServer(ChosenBrick.Name , ID)
					Brick:Destroy()
				end
			end)
		end
		if Brick:IsA("BasePart") then
			Touched(Brick)
		else
			for i,v in ipairs(Brick:GetChildren()) do
				if v:GetAttribute("Brick") and v:IsA("BasePart") then
					Touched(v)
				end
			end
		end
		game:GetService("Debris"):AddItem(Brick,60)
1 Like

If you want a part to be client-sided, it needs to be created on the client with :Clone() or parented to workspace on the client if it wasn’t there before.

The part is on the client side and is cloned through the client script. My issue is other players being able to interfere with the unanchored part.

You mean that other player’s can accidentally move the client-sided parts? You should be able to avoid that with CollisionGroups, making it so that the unanchored parts and other players are in different collision groups that can’t collide.

Thanks! But by any way, could you please tell me how to do this? I’m unsure on how to do it. Can I do it through the client or just the server?

Since the part’s only exist on the clients, you have to do it on the clients. You can, for example, make 2 new collision groups in studio called “Brick” and “OtherPlayer”, which you set to not collide with each other (scroll down to “Collision Groups” Collisions | Documentation - Roblox Creator Hub). Then, whenever you locally create a new part, just set it’s collision group (BasePart.CollisionGroup) to “Brick”. And whenever someones character (that isn’t the client’s character) loads in, you loop through every part in the character and set their collision groups to “OtherPlayer”.

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.