Hello, I am making a game where you have to copy a build but I have no idea where to start.
All of the builds are 5x5x5 blocks.
Could anybody please help me?
Hello, I am making a game where you have to copy a build but I have no idea where to start.
All of the builds are 5x5x5 blocks.
Could anybody please help me?
What is a build checking system?
I’m guessing they mean a system which can check whether something you built is identical to a given build, which Players have to copy as part of the OP’s game’s objective.
You can simply loop trought every part of the model and check if there’s in the player build the same part at a certain position from the middle of the model if you see what I mean !
But there is no way to check if a part exists using a CFrame
Oh I understood, do you mean like iterating through the players’ build and the original build, and check differences like that?
If yes that should work, but could be pretty laggy as 5x5x5 = 125 and 125 x 8 = 1000 and 1000 x 1000 blocks to check if the space if full.
Maybe I’ll implement a checking cinematic so that it won’t lag the server.
8 for the maximum number of players,
5x5x5 for the dimensions,
*and 1000x1000 because for each I need to do 1000 checks, but 1000 times.
I will try this and if it works without too much lag I will mark you post as the solution.
Have a nice day!
EDIT: The reason I’m taking so long is because I have to change half of my code and create the matchmaking system for me to implement this.
Hey, I’m really sorry to bump this and notify you, but I can’t figure out how to code it.
Could you please help me? It always says I won even though I didn’t.
Here is my code:
for _, Zone in pairs(BuildingZones) do
if Zone:GetAttribute("userID") ~= nil then
local loose = false
for _, currentBlock in pairs(Zone.Blocks:GetChildren()) do
for _, OriginalBlock in pairs(BuildPlatform.Build:GetChildren()[1].Blocks:GetChildren()) do
print(currentBlock.CFrame:ToObjectSpace(Zone), OriginalBlock.CFrame:ToObjectSpace(OriginalBlock.Zone))
if currentBlock.Name == OriginalBlock.Name and currentBlock.CFrame:ToObjectSpace(Zone) == OriginalBlock.CFrame:ToObjectSpace(OriginalBlock.Zone) then
else
loose = true
end
end
end
local playerId = Zone:GetAttribute("userID")
local player = if playerId then PlayersService:GetPlayerByUserId(playerId)
else nil
if not player then
continue
end
table.insert(if loose then loosers else winners, player.Name)
end
end
WinnersRemote:FireAllClients(table.concat(winners, ", "))
LoosersRemote:FireAllClients(table.concat(loosers, ", "))
print("won", table.unpack(winners))
print("lost", table.unpack(loosers))
for _, Zone in pairs(BuildingZones) do
Zone.Blocks:ClearAllChildren()
end
BuildPlatform.Build:ClearAllChildren()
matchStarted = false
end
end
Ok let me 2 mins !
And don’t worry of notify me lol
Ok so I made this function that will return you a ranking of all players :
local Zones = workspace.Zones:GetChildren()
local Model = workspace.Model
local function GetResults()
local Results = {}
local MaxCorrespondence = #Model:GetChildren()
for v, Zone in pairs(Zones) do
local Correspondence = 0
for v, Part in pairs(Zone:GetChildren()) do
local ZoneCenter = Zone.Center
if Part ~= ZoneCenter then
for v, OtherPart in pairs(Model:GetChildren()) do
local ModelCenter = Model.Center
if OtherPart ~= ModelCenter then
local Position = Vector3.new(math.round((Part.Position.X - ZoneCenter.Position.X) * 10) / 10, math.round((Part.Position.Y - ZoneCenter.Position.Y) * 10) / 10, math.round((Part.Position.Z - ZoneCenter.Position.Z) * 10) / 10)
local OtherPosition = Vector3.new(math.round((OtherPart.Position.X - ModelCenter.Position.X) * 10) / 10, math.round((OtherPart.Position.Y - ModelCenter.Position.Y) * 10) / 10, math.round((OtherPart.Position.Z - ModelCenter.Position.Z) * 10) / 10)
if Position == OtherPosition and Part.Name == OtherPart.Name then
Correspondence += 1
end
end
end
end
end
table.insert(Results, {["UserId"] = Zone:GetAttribute("UserId"), ["Score"] = Correspondence > 0 and Correspondence / MaxCorrespondence or 0})
end
table.sort(Results, function(a, b)
return a["Score"] > b["Score"]
end)
return Results
end
Note that in my script I consider that you’re zone are in a folder and that zones are model or folder idk but they contains only parts, same for the model !
I hope that was helpful and have a nice day !!!
I will mark this post as the solution as it is the idea behind it that works.
The problem is that the code doesn’t work, like for example the .Center
proprety doesn’t exist.
It is not a property in fact, it is the part that is 5x5x5 and in the middle of your zone !
EDIT : I will show you an exemple of what I mean
Oh do you mean like the point from which it’ll check the position?
If yes, why not use .Position on my Zone part? It would always be in the center.
Yes, it should work I wasnt aware that you’ve already have one :
Center is the big cube and all little parts are your things !
Ohhhhh, Center was meant to be a part? I’m so dumb! I’m just going to replace it with Zone as that’s what the big part is called in my game.
Also in your code you’re doing part.position.position sometimes lol
EDIT: Also why do you use math.round()?
Your explorer should look like this :
And the model is another folder with the same structure as player’s zones but with part at the good positions !
Where do I do position.position ?
And I do this cause else magnitudes will never be equal due to .0000001 things lol
My explorer looks like this:
I’m going to adapt the code for that.
Sorry for the misunderstanding!
local ModelCenter = OriginalBuild.Zone.Blocks:GetChildren().Position
-- Somewhere else in the code
OtherPart.Position.X - ModelCenter.Position.X -- Which is equal to Model.Position.Position.X