Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

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

Asked by 2 years ago
Edited 2 years ago

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

Log in to vote
1
Answered by
AronYstad 101
2 years ago
Edited 2 years ago

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

0
Where do I put this script...? In every 'dropperscript' or just one script? I'm confused. Krektonix_Youtube 85 — 2y
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. Krektonix_Youtube 85 — 2y
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. AronYstad 101 — 2y
Ad

Answer this question