Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
COMMUNITY QUESTION

How do I render the scene with a ViewportFrame but only for a player?

Hello! I'd ask this in the Roblox Dev Forum, but I'd need to spend more time there, which apparently two hours is not enough.

I have no clue how I'd code this, but I've looked at a few scripts which do not do what I want to do.

I was trying to render the player at the same part of the scene, with the exact same rotation to build a base on a faked motion blur effect.

I do not have any code samples, as Google is failing me on how to even render a player in the ViewportFrame!

Basically just something like this

1 answer

That wouldn't be very effective to do through a ViewportFrame... I tried it and I came up with this.

Insert this in StarterGui with a LocalScript and it should work! You can tweak timings if you want more clones etcetera!

local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local Debris = game:GetService("Debris")
local RunService = game:GetService("RunService")
char.Archivable = true -- Calling Clone directly on an object will return nil if the cloned object is not archivable.

while wait(0.2)
do
	local human = char:FindFirstChild("Humanoid")
	if human then -- Check for humanoid (player could die)
		if not player.Idled then -- Stop the script if player goes idle because why not
			local clone = char:Clone()
			Debris:AddItem(clone, 0.6) -- Clone will have a 0.6 lifetime.
			clone:FindFirstChild("HumanoidRootPart"):Destroy()
			clone:FindFirstChildWhichIsA("Humanoid").DisplayDistanceType = Enum.HumanoidDisplayDistanceType.None
			
			for i,v in pairs(clone:GetDescendants()) do -- Get all the children
				if v:IsA("BaseScript") then
					-- Destroy any scripts
					v:Destroy()
				elseif v:IsA("BasePart") then
					-- Make it non-collidable and anchored
					v.CanCollide = false
					v.Anchored = true
				end
			end
			-- Now that the clone has been handled, display it
			clone.Parent = workspace 
			
			spawn(function() -- Fade script
				for i = 0,1,1/3 do
					for _,v in pairs(clone:GetDescendants()) do
						if v:IsA("BasePart") then
							v.Transparency = i
						end
					end
					wait(0.2)
				end
			end)
				
		end
	end
end

I commented it fairly thoroughly but let me know if you have any questions!

Hope it helps!

1 comment

0

It doesn't seem to show up..

This discussion is preserved as it was. New answers, comments, and votes are closed.