#Grid building system override

94 messages · Page 1 of 1 (latest)

split marten
#

video:

#
Placement.Snap = function(n)
    return math.round(n / grid_size) * grid_size
end


local TS = game:GetService("TweenService")

Placement.GetPos = function()
    if obj and obj.Parent == placedobj and grid_size then
        PosX = Placement.Snap(mouse.Hit.X)
        PosY = Placement.Snap(mouse.Hit.Y) + obj.Size.Y / 2
        PosZ = Placement.Snap(mouse.Hit.Z)
    else
        PosX = mouse.Hit.X
        PosY = mouse.Hit.Y
        PosZ = mouse.Hit.Z
    end
end

these are the snap and getpos functions

#
Placement.Place = function()
    if CanPlace == true and checkCooldown == false and obj then
        checkCooldown = true
    
        if obj.Parent == placedobj then
            game.ReplicatedStorage.pobj:FireServer(objname, PosX, PosY, PosZ, mouse.Hit)
            obj:Destroy()
        else
            obj:Destroy()
        end
        
        
        Placement.New(cooldown, objname, itemfolder, placedobj, grid_size)
        task.wait(cooldown)
        checkCooldown = false
    end
end

this is the place function

#

im really confused

drowsy pumice
#

1st

#

dont round it

#

floor or ceil it

split marten
#

alright

#

but its kinda wrongly placed

#

if i floor it

#

and well the problem still persists

drowsy pumice
split marten
#

anyone?

scarlet cedar
#

bro just followed b ricey's codes 💀

split marten
#

i took inspiration

scarlet cedar
#

copy*

split marten
#

no

#

not at all

scarlet cedar
#

ok

split marten
#

also no its not him anyways

pallid needleBOT
#

studio** You are now Level 9! **studio

scarlet cedar
#

nice then

split marten
#

i just took the snap fucntion

#

since i didnt know how to do the grid

scarlet cedar
#

same

split marten
#

i ong have no idea how to fix it

drowsy pumice
#

i know the fix but

#

😭

split marten
#

just uhm

#

i have a feeling that

#

im doing the client-to-server wrong

#

just tell me please

drowsy pumice
#

nah bro uhhh

#

idk man i am really bad with other ppl code

split marten
#

please

#

just tell me whats wrong

#

not the code

#

just whats wrong

#

i tried region3d, i tried firing the stuff from the server, i tried using tables, i tried using raycasts, i tried using collission groups I DONT KNOW WHATS WRONG

#

@drowsy pumice

drowsy pumice
#

wait whats the exact issue

#

blocks overlapping?

#

@split marten

split marten
#

yeah, and also horizontal building

#

if i tried to make a bridge (like minecraft), they would stack up on the same block

drowsy pumice
#

you do this

#

u get .Mouse

#

u get its target

#

u check if its a block

split marten
#

yeah

drowsy pumice
#

or something u can build on

#

then u get the surface

split marten
#

.surface?

drowsy pumice
#

Mouse.TargetSurface

#

then according to that

#

u render the new block

#

in the position off the old block

#

offset with the surface offset value

#

one second

split marten
#

but the problem is that

#

nvm

#

keep going

drowsy pumice
#

sorry for the messy code

            elseif Target.Parent.Name == "BuildContainer" then
                OutOfBounds = false
                if Mouse.TargetSurface == Enum.NormalId.Front then
                    RB.Position = Target.Position + Vector3.new(0,0,-3.5)
                elseif Mouse.TargetSurface == Enum.NormalId.Back then
                    RB.Position = Target.Position + Vector3.new(0,0,3.5)
                elseif Mouse.TargetSurface == Enum.NormalId.Left then
                    RB.Position = Target.Position + Vector3.new(-3.5,0,0)
                elseif Mouse.TargetSurface == Enum.NormalId.Right then
                    RB.Position = Target.Position + Vector3.new(3.5,0,0)
                elseif Mouse.TargetSurface == Enum.NormalId.Top then
                    RB.Position = Target.Position + Vector3.new(0,3.5,0)
                elseif Mouse.TargetSurface == Enum.NormalId.Bottom then
                    RB.Position = Target.Position + Vector3.new(0,-3.5,0)
                end
                RB.Parent = BuildSpace
#

that basically

#

then

#

when the player clicks

split marten
#

yeah

drowsy pumice
#

u send the proper offset position to server

#

the server checks if u can place a block there

#

if its valid

#

the server places the block

#

not the client

#

unless u want to

#

keep the blocks hidden from other clients

#

dont mind the 3.5

#

its just ur block size

split marten
#

and then i recheck again all of that in the server?

#

ITS STILL NOT WORKING

drowsy pumice
split marten
#

maybeee its because the parent of the obj is being set in the server

drowsy pumice
#

bruh

split marten
#

bro im so confused

#

the parent is not even right

#

I give up

split marten
#

nvm i fixed it thanks

#

it was the mousefilter

#

i was filtering the placed objects, thats why i couldnt get their parent