How do I make a script that only renders parts if the player is within a certain distance from them
Try using stream service it’s inside workspace.
local part = workspace.Part
local character = game.Players.LocalPlayer.Character
local goneDistance = 10 -- how far must the part be from the player for it to gone
while wait() do
if (part.Position - character.PrimaryPart.Position.Magnitude) > 10 then
part.Parent = game.ReplicatedStorage
else
part.Parent = workspace
end
end
but if its for optimization i recommend to just use stream service.
1 Like