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

How would i make an infinite map without causing lag?

Asked by 5 years ago

Hello, for one of my games i am making i'd like to make a map that generates as any player moves around i know about streamingenabled but my problem comes with server lag, so my best idea is to generate everything on the client, but i'm not too sure how to send information to other clients if anything on the map is changed, my idea is to replicate the change to server then back to clients and store the changes in the server, so when a new player joins the server can send the already existing information to the client.

2 answers

Log in to vote
0
Answered by
royaltoe 5144 Moderation Voter Community Moderator
5 years ago

You have the right idea about loading it locally. I'd seperate the map into model chunks and only load each chunk if the character is within a certain distance from it's primary part. If it's close enough then I'd load the model a part at a time to avoid the lag from cloning a giant model into the game.

Ad
Log in to vote
0
Answered by 5 years ago

Instruction 1. Make all the parts in the Workspace INVISIBLE (Transparency to 1) 2. Insert in all part a BOOL VALUE with the Name RENDABLE (if you have to parts in the workspace, then use the second script) 3.Insert this in a LocalScript

--[Made 100% by Eternalove_fan32(PLS CREDITS)]--
--(sorry for bad englisch)

local RenderMaxDistance = 50 -- in Studs (Modifie only here)
local RenderMinDistance = 0 -- in Studs (Modifie only here)


local RendableParts = game.Workspace:GetDescendants() -- Hold all the Objects in the workspace

while true do
    wait(1)
    for i,Part in pairs(RendableParts)do
        if Part:IsA("BoolValue")then -- Check if the Object is a BoolValue
            if Part.Name == "Rendable"then -- Check if the Object is the BoolValue for the Rendering and not another
                -- Variable
                local RenderPart = Part.Parent
                -- Position
                local RenderPartPosition = RenderPart.Position
                local HumanoidRootPart = script.Parent:FindFirstChild("HumanoidRootPart")
                local HumanoidRootPartPosition = HumanoidRootPart.Position

                local RenderMagnitude = (RenderPartPosition - HumanoidRootPartPosition).Magnitude -- Calcule the Distance between the Player and the Parts that soll be render 

                -- Check if the Player was not to far or to close
                if RenderMagnitude >= RenderMinDistance and RenderMagnitude <= RenderMaxDistance then
                    -- if the Player was not to far or to close then render the Part
                    Part.Parent.Transparency = 0
                else
                    -- else not Render the Part
                    Part.Parent.Transparency = 1
                end
            end
        end
    end
end

Script Number 2:

local RendableParts = game.Workspace:GetDescendants()

for i,part in pairs(RendableParts) do
    if part:IsA("Part") or part:IsA("MeshPart") then
        local Bool = Istance.new("BoolValue", Part)
        Bool.Name = "Rendable"
    end
end

Answer this question