generic image
Processing...
  • Games
  • Catalog
  • Develop
  • Robux
  • Search in Players
  • Search in Games
  • Search in Catalog
  • Search in Groups
  • Search in Library
  • Log In
  • Sign Up
  • Games
  • Catalog
  • Develop
  • Robux
   
ROBLOX Forum » Game Creation and Development » Scripters
Home Search
 

Re: Load Parts Smoothly

Previous Thread :: Next Thread 
KAMIKAZEPOLO is not online. KAMIKAZEPOLO
Joined: 14 Mar 2012
Total Posts: 1049
08 Aug 2015 10:27 PM
I'm making a script that loads models into workspace. However, I just use (game.ServerStorage.Model.Parent = game.Workspace), this lags the game. Is there a way to stream load these parts or at least load them in so they don't lag as much?
Report Abuse
iSpecializinq is not online. iSpecializinq
Joined: 31 May 2015
Total Posts: 2182
08 Aug 2015 10:30 PM
workspace.StreamingEnabled

look it up
Report Abuse
lostend is not online. lostend
Joined: 21 Aug 2011
Total Posts: 8265
08 Aug 2015 10:35 PM
put it in replicatedstorage; or load each part one by one.
Report Abuse
baldo46 is not online. baldo46
Joined: 28 Jul 2008
Total Posts: 1254
08 Aug 2015 11:00 PM
load in sections/chunks
Report Abuse
lostend is not online. lostend
Joined: 21 Aug 2011
Total Posts: 8265
08 Aug 2015 11:13 PM
heres a cool way to load it. dont expect it to work, i wrote it on this thread on mobile. No testing

function getAllChildren(ins)
d={}
for _,v in next,ins:GetChildren() do
d[#d]=v
if #v:GetChildren()>0 then
getAllChildren(v)
end
end
return d
end

function loadMap(map)
local contents,newmap=getAllChildren(map),Instance.new('Model',workspace')
newmap.Name=map.Name
for i=1,#contents do
local _new=contents[i]:Clone()
_new.CFrame=_new.CFrame*CFrame.new(0,5,0)
_new.Transparency=1
for t=1,contents[i].Transparency,-.1 do
_new.Transparency=t
wait()
end
end
end
Report Abuse
baldo46 is not online. baldo46
Joined: 28 Jul 2008
Total Posts: 1254
08 Aug 2015 11:24 PM
function getDescendants(obj)
local d = {};
for _,v in pairs(obj:GetChildren()) do
table.insert(d,v); -- functions are nice, rite?
if (#v:GetChildren() > 0) then
table.insert(d, unpack(getDescendants(v)));
end
end
return d;
end

function loadMap(map)
local contents = getDescendants(map);
local newMap = Instance.new("Model", workspace);

newMap.Name = map.Name;
--without coroutines will take literally an hour
for i,v in pairs(contents) do
coroutine.wrap(function()
local new = v:Clone();
--new.CFrame = new.CFrame;--*CFrame.new(0,5,0);--why move up 5?
new.Transparency = 1;
new.Parent = newMap;
for t=1, v.Transparency, -0.1 do
new.Transparency = t;
wait()
end
end)()
end
end

--nob toilet learn how to recursively do functions or don't do them at all.


My suggestion again, is to use chunking. If your map scripts rely on parent/child relationships to get certain parts, this script is useless because it dumps all the parts into a single table. ALSO forgot, add a check if v:IsA("BasePart") thing in there.
Report Abuse
2JJ1 is not online. 2JJ1
Joined: 15 Mar 2012
Total Posts: 1571
08 Aug 2015 11:24 PM
Well, this script can load things into the workspace 1by1

function LOAD()
for i,v in pairs (game.ServerStorage.Model:GetChildren()) do
wait(0.05)
v:Clone().Parent = game.Workspace
end
end



_____________________________________________________________________
Lets work as a team? http://www.roblox.com/My/Groups.aspx?gid=2638401
Report Abuse
baldo46 is not online. baldo46
Joined: 28 Jul 2008
Total Posts: 1254
08 Aug 2015 11:29 PM
a step in the right direction; however, how do you expect him to remove the map if you don't specify a map Model.
Report Abuse
2JJ1 is not online. 2JJ1
Joined: 15 Mar 2012
Total Posts: 1571
08 Aug 2015 11:32 PM
I figured that he would figure it out, it is only an example to give an idea so I didn't want to make the script long.


Make a model in the Workspace and name it Map.
Make the cloned object's parent the Map model in Workspace. If the map needs to be removed, game.Workspace.Map:ClearAllChildren()



local part = Instance.new("Part")
part.Anchored = true
part.CanCollide = false
part.Position = points[2]
part.Parent = script.Parent.Model
Report Abuse
2JJ1 is not online. 2JJ1
Joined: 15 Mar 2012
Total Posts: 1571
08 Aug 2015 11:32 PM
OOps, ignore those last 5 lines. Meant to paste my sig :#



_____________________________________________________________________
Lets work as a team? http://www.roblox.com/My/Groups.aspx?gid=2638401
Report Abuse
Previous Thread :: Next Thread 
Page 1 of 1
 
 
ROBLOX Forum » Game Creation and Development » Scripters
   
 
   
  • About Us
  • Jobs
  • Blog
  • Parents
  • Help
  • Terms
  • Privacy

©2017 Roblox Corporation. Roblox, the Roblox logo, Robux, Bloxy, and Powering Imagination are among our registered and unregistered trademarks in the U.S. and other countries.



Progress
Starting Roblox...
Connecting to Players...
R R

Roblox is now loading. Get ready to play!

R R

You're moments away from getting into the game!

Click here for help

Check Remember my choice and click Launch Application in the dialog box above to join games faster in the future!

Gameplay sponsored by:
Loading 0% - Starting game...
Get more with Builders Club! Join Builders Club
Choose Your Avatar
I have an account
generic image