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

How To Check for Spaces Beneath a Brick?

Asked by
Legojoker 345 Moderation Voter
10 years ago

In my game, I need to make sure that when a building is placed, there are no crevices or openings beneath the base plate brick of my building models. All of these are named Torso and are set as the primary part of the model. When a player clicks, to place a building, the client sends a request to the server about placing it, and it can go through a simple check: Will the building be on the same plane as where the client put it? If not, remove it. Then it checks for if the player who placed the building is still there and can pay for it (the client has already confirmed that he or she has enough money so I figured ANOTHER check for that would be pointless.)

Since the building is centered on the point where the player clicked, on rough terrain, buildings can end up "dangling" over edges Like in this picture: http://prntscr.com/4inl86

The code below is what I use to check for building placement. I hope someone knows some sort of method, I'm completely lost. Thanks for your help!

game.Workspace.Inputs.ChildAdded:connect(function(c)
    if c.Name == "Building" then
        local bldg = storage[c.Value]:Clone()
        bldg.Team.Value = c.Team.Value
        bldg.Parent = game.Workspace.TestBuild
        bldg:MoveTo(c.Location.Value)
        if math.abs(bldg.Torso.Position.Y-Location.Value.Y) < .2 then
            if something then -- something, implying whatever I have to do to check for uneven terrain.
                local paid = false
                for _,v in pairs(game.Player:getChildren()) do
                    if v.TeamColor == c.Team.Value then
                        v.Cash.Value = v.Cash.Value-storage[desired].Cost.Value
                        paid = true
                    end
                end
                if paid then
                    if c:findFirstChild(TPTank) then c.TPTank.Value:destroy() end
                    bldg.Parent = game.Workspace
                else
                    bldg:destroy()
                end
            end
        else
            bldg:destroy()
        end
    end
    c:destroy()
end)
0
Shouldent the money check be on the server? If it's checked on the client couldent they use CE to cheat? iaz3 190 — 10y
0
Cheat engine lol, those were the days, back when we couldn't just run any code we wanted. theCJarmy7 1293 — 6y

Answer this question