#Making server objects less laggy

1 messages · Page 1 of 1 (latest)

devout halo
#

I am making a single-player game about combining cubes, so far it has 1 main server script and 2 modules required in it (see them bellow)

Problem: Pushing cubes (cloned off a template in server storage, via server script) is super laggy, where pushing cubes cloned with a local script isn't laggy at all. How do i fix this ( all cubes are massless )? (see video)

Why do i want the server to recognise them, and not the client only? Later on, I want to give the players multiple uses for cubes, like selling, crafting, etc... ( where server is needed ).

If there is no way of making server objects less laggy, I heard there is a way to make them render through client first then connect to server ( got no clue how that's done )

Please note I am not experienced.

brisk skiffBOT
#

studio** You are now Level 5! **studio

graceful maple
#

the problems probably not woth the scripts at all—its likely just player hotboxes. try going to the avatar tab n adding consistent hitboxes. switching to r6 might also help

#

if its still too laggy, you could try making a custom hitbox part by duplicating one to every humanoid and making them only collide with the boxes

#

switching from server scripts to localscripts might also cut back lag. if the servers lagging, then the boxes are lagging—in a localscript, however, the boxes will only lag if youre lagging

#

another fix might to just be simply putting a script in every box that makes them more sensitive to collosions

graceful maple
#

yeah

devout halo
devout halo
graceful maple
#

ill come back to that

devout halo
#

i assume this many boxes wouldn't make server lag too bad

graceful maple
# devout halo enabled that + r6, no difference

im assuming youre having the boxes being taken out of serverstorage and duplicated, so you could try putting a script inside of each box that makes their physics more sensitive, and more prone to sliding

#

you could also gove the player a custom, bigger hitbox, but that sounds like a pain in the ass

graceful maple
devout halo
graceful maple
#

jhhdnrmdixhehehrnrjsjdjhrrnrkidhfnrndixucnrnrkekdic in fbrnejxhcuit

#

sorry im trying to think stroaght its 5 am gove me a moment

#

oh eait no just trll it to change the physical mass property in the script

#

like

#

ok

#

pocture this

#

you got a part in the work space

#

you put a server script in it

#

you tell gpt to do whatever (tell it to modify the physical properties manually in the script instead of doing hard, hard labor)

#

and then boom done

devout halo
#

all the parts in the model are already massless

graceful maple
#

what about friction and elasticity

devout halo
graceful maple
#

lower friction = more slide

#

so like try something real low then

#

like 0.03

#

low elasticity is just for bounce but i might help it

devout halo
#

problem is they are super super laggy

graceful maple
#

are you not running it in studio?

devout halo
#

its in studio

graceful maple
#

s9rry sorru

#

uuyuuhhhdbdhdbfnf

#

this is rough jesus ok hold on

#

idea okay

#

since the model has more than like one part, it might be all trying to keep up but struggling

#

to fix this, maybe you could put s transparent shell around each cube that the player can collise with in order to push it properly

devout halo
graceful maple
#

i forgot if you said this already but also make sure everything youre trying tk lush is unmass

graceful maple
#

maybe theres too much friction eith the baseplate?

devout halo
#

cubes don't lag at all there, even when so many

graceful maple
#

is it a 1 player game?

devout halo
devout halo
graceful maple
#

oh if youre going for just an independent game where theres no multiplayer definitely switch everything you can to localscripts in starterplayer if it isnt there already

graceful maple
devout halo
devout halo
graceful maple
#

hold on try a cube like just a normal part

#

see how that goes

devout halo
#

alr ima do that rq

limpid chasm
#

no wonder its lagging

devout halo
#

i did a test push without frames, its not as laggy, but still laggy

limpid chasm
devout halo
#

initially i wanted it to stick out and be neon

limpid chasm
devout halo
limpid chasm
# devout halo i mean only the frames neon

put the highlight inside the walls of the cube then clone the walls and move them up a tiny bit then make sure the surfaceguis r only inside the outerwalls and then it should work (if u cant see the outline then scale its height and width slightly until u can)

#

then delete the highlights out the the new walls

devout halo
#

ty, will try that

limpid chasm
devout halo
#

this looks nice already without highlight

devout halo
limpid chasm
limpid chasm
#

highlights need humanoids to work btw

devout halo
#

i just discovered smth

brisk skiffBOT
#

studio** You are now Level 6! **studio

limpid chasm
devout halo
#

it sticks out aswell

limpid chasm
#

at least i dont think never rly used them

graceful maple
#

ok sorry im back what happened

brisk skiffBOT
#

studio** You are now Level 6! **studio

devout halo
limpid chasm
limpid chasm
graceful maple
#

did one individual brick push smoothly?

devout halo
limpid chasm
devout halo
brisk skiffBOT
#

studio** You are now Level 7! **studio

devout halo
limpid chasm
#

ok

#

yes

graceful maple
#

did you try updating the network owner to the player instead of the server?

limpid chasm
#

lemme explain tho:

devout halo
graceful maple
limpid chasm
#

set the transparency of the cube to high but not 1 so like 0.5 or smth

#

then set the color of the highlight to whatever color u want

limpid chasm
devout halo
limpid chasm
graceful maple
#

you guys seem like you got this

#

im gonna go to bed

limpid chasm
graceful maple
#

ive been up all night and its like 6 am

#

goodluck soldiers

devout halo
#

gn

devout halo
limpid chasm
devout halo
limpid chasm
devout halo
#

after 20 billion errors i got it to give me no error

#

put it here

#

pushing cubes is still laggy

#

idk why i can't even push the bigger ones

limpid chasm
#

show me ur cube placeholder (the objs inside it in explorer view yk)

devout halo
#

this? in server storage

#

i will remove them frames but i gotta modify scripts

limpid chasm
devout halo
#

took as an example this cube , removed its frames, set its network owner, still laggy to push

limpid chasm
devout halo
#

i don't think it will fit in 20 screenshots

rough kindle
#

😭

#

No one can write Em-Dashes in PC unless they use the Alt + num method

#

except on mobile

devout halo
#

i use em a lot

limpid chasm
rough kindle
#

Assuming all parts are unanchored

#

In server it would be laggy as it has to replicate through all clients

rough kindle
#

In client it wont be the same, as its only replicated through one client and no one else it wouldnt really do anything too heavy

devout halo
rough kindle
#

And you dont need to post your games architechture i already told you the problem

devout halo
rough kindle
#

If you want to have pushing into your game, id reccomend only unanchoring when needed

#

Hope this helps.

devout halo
#

but then i realised i wanted ppl to be able to sell/use them for stuff

limpid chasm
# devout halo

do not store all that in workspace put it in serverstorage also u dont need to even store it physically, any different colors, transparency, etc between cubes, store them in a module script

devout halo
#

this is just the old way i used to do it

limpid chasm
#

store 1 placeholder cube

devout halo
limpid chasm
devout halo
#

i will just delete the templates from workspace since yeah, i do not need em anymore

rough kindle
#

But again, if you want to have pushing

#

Use server, unanchor when needed

devout halo
#

main feature of my game is pushin

limpid chasm
devout halo
rough kindle
#

Unanchor when a player touches the object

#

As if theres 10 players, it would still give out lag

devout halo
#

when part touched unanchor?

limpid chasm
rough kindle
#

If used proximity

devout halo
#

ohh i think i understand now

#

unanchored parts still make roblox do physics calculations-even if stationary

limpid chasm
limpid chasm
devout halo
#

will i achieve such thing doing what u said @rough kindle ?

limpid chasm
devout halo
#

i am not talking about the combining-i am talking about the pushing

limpid chasm
# devout halo so...some proximity thing?

so make a function to get the nearest plr and if theyre less than 10 studs away unanchor smth like this:

    local closest = nil
    local closestDist = math.huge

    for i, plr in ipairs(plrs:GetPlayers()) do
        local chr = plr.Character
        
        if chr and chr.PrimaryPart then
            local hum = chr:FindFirstChild("Humanoid")
            
            if hum and hum.Health > 0 then
                local dist = (chr.PrimaryPart.Position - nextbotHrp.Position).Magnitude
                
                if dist < closestDist then
                    closestDist = dist
                    closest = chr
                end
            end
        end
    end

    return {closest, closestDist}
end```
limpid chasm
devout halo
#

it won't cause any lag right?

limpid chasm
#

literally just this:
local dist = (chr.PrimaryPart.Position - nextbotHrp.Position).Magnitude

limpid chasm
limpid chasm
devout halo
limpid chasm
#

also enable this (look at the sent and recv if their high ur game is horribly optimised):

devout halo
limpid chasm
limpid chasm
devout halo
#

its the same as it was when i made this post

#

i think cubes aren't anchoring, gotta fix that

limpid chasm
#

my game

devout halo
#

i think best way is just to locally spawn them

#

and use remote events/functions in order to let server know what the player wants to do

#

(sell, craft, etc)

limpid chasm
devout halo
#

something like SellCubeEvent:FireServer(cubeID)

devout halo
#

I have been at this optimising server spawning stage for way too long, no results

devout halo
limpid chasm
devout halo
limpid chasm
devout halo
#

i want cubes to save ( will do it much later )

#

see now they slide easily

#

but why are four sized cubes so much harder to push?

limpid chasm
# devout halo

looks fine to me, considering ur stats r fine, maybe its just ur computer? what is ur pcs specs?

limpid chasm
devout halo
devout halo
limpid chasm
#

sry capslock

limpid chasm
devout halo
#

" setting a cube to Massless = true in Roblox makes its physics ignore the part’s actual mass. The result is that all cubes, regardless of size, require the same force to move. "

devout halo
#

what is going on here?

#

each frame is set to massless too

limpid chasm
# devout halo what is going on here?

seems to me that its fine, its prolly bc its bigger that it looks like its heavier. just watch it again although it looks like its heavier it takes the same time to move each cube

devout halo
#

its clearly harder to push

#

i can barely move the 4th one

limpid chasm
#

oh thats very weird

devout halo
#

i will make a new post on that, since i achieved the purpose of this one

brisk skiffBOT
#

studio** You are now Level 7! **studio

devout halo
#

won't use this thread anymore

sonic umbra
#

Make the parts massless

#

Yeah I didn’t read anything

graceful maple