Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How to I make Ores not hit each other in Zonix's Simple Sandbox Tycoon Kit?

I am using this kit > https://devforum.roblox.com/t/simple-sandbox-tycoon-kit/1488280 for a sandbox tycoon game like Miners Haven.

So, I want ores to not hit each other, so like a cancollide. But obviously they need to be anchored so they wont fall through the map and delete. So how do I make the ores not collide with players or themselves?

1 answer

Use collision groups.

local PhysicsService = game:GetService("PhysicsService")

--Create the collision groups.
PhysicsService:CreateCollisionGroup("Players")
PhysicsService:CreateCollisionGroup("Ore")

--Add the BaseParts in every player's character to the collision group "Players".
game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		for i, part in pairs(character:GetDescendants()) do
			if part:IsA("BasePart") then
				PhysicsService:SetPartCollisionGroup(part,"Players")
			end
		end
	
	end)
end)

--Make players not collide with ores, and ores not collide with ores.
PhysicsService:CollisionGroupSetCollidable("Players","Ore",false)
PhysicsService:CollisionGroupSetCollidable("Ore","Ore",false)

and then use this when the ore is spawned:

--Add the ore to the collision group "Ore".
PhysicsService:SetPartCollisionGroup(Ore,"Ore")

where Ore (the variable, not the string) is the ore that spawned.

Here is an article that explains it: https://developer.roblox.com/en-us/articles/Collision-Filtering

3 comments

0

Where do I put this script...? In every 'dropperscript' or just one script? I'm confused.

0

So, good news it works. BAD NEWS is that it breaks the entire game and you cannot pickup objects, place them, etc. And if I disable that then the character falls through the map.

0

You only need to run the first script once. Then you put the second script in every dropper script. Also, I need a bit more information to tell what went wrong.

This discussion is preserved as it was. New answers, comments, and votes are closed.