I would like to grab the current players from my game, the models specifically, and place their model (or a clone rather) in a viewport frame. my local script below clones and enables archiving so that isn’t the issue. The issue is below.
Here is me grabbing the players, but the same player in viewport frame
Player1 is running Player2 is stationary, but in the viewport frame they’re both running, meaning that only one player character is being displayed.
My current set up works to an extent it duplicates my own player character though, it doesn’t clone the other player characters. As seen above in the screenshot.
Reason I think why here
The localscript is housed in the template, and its grabbing the player.Character, me? After its cloned its still grabbing my player character. even for both templates that have been cloned and repurposed for each player, mimicking their names at least. but not their respective player.Characters.
I cannot seem to find any solutions to this particular problem. I’ve searched far and wide, I don’t want to animate the viewport frames I just want to see a pic of their character. and everything I’ve found has been animating viewport frames, or doing everything client side. I need it to be server/client side.
Code here
----Local Script inside the template that also houses the viewport frame--
local zoomOut = 5
local VPF = script.Parent:WaitForChild("ViewportFrame")
local player = game.Players.LocalPlayer
function render(object)
local cam = Instance.new("Camera")
object.Archivable = true
local clone = object:Clone()
clone.Parent = VPF
local cam = Instance.new("Camera")
cam.Parent = VPF
pcall(function()
if object:IsA("Model") and object.Humanoid and object.Head then
cam.CFrame = CFrame.new(clone["Head"].Position + (clone:WaitForChild("Head").CFrame.lookVector * zoomOut)+ Vector3.new(0,1,0), clone.Head.Position)
elseif object:IsA("Part") then
cam.CFrame = CFrame.new(clone.Position + (clone.CFrame.lookVector * zoomOut)+ Vector3.new(0,1,0), clone.Position)
end
end)
VPF.CurrentCamera = cam
end
function ResetVPF()
VPF:ClearAllChildren()
VPF.CurrentCamera = nil
end
wait()
ResetVPF()
render(player.Character)
---- ServerScript function that adds players to frames----
local function addToFrame(player) -- Add Player Frames to Gui
local MainAdmin = player.PlayerGui.Admin:WaitForChild("AdminButton")
local MainUi = MainAdmin:WaitForChild("MainUi")
local pI = MainAdmin:WaitForChild("PlayerInfo")
local Template = MainAdmin.Parent.LocalScript:WaitForChild("Template")
---Getting all local Players
for _, plr in pairs(game:GetService("Players"):GetPlayers()) do
print(plr)
---Creating Templates for each player
local NewTemplate = Template:Clone()
NewTemplate.Name = plr.Name
NewTemplate.PlayerName.Text = plr.Name
NewTemplate.PlayerName.Name = plr.Name
NewTemplate.Parent = MainUi
end
end
Been trying to work on this for 2 solid days with little breaks, Its driving me insane, I’m thinking about creating a thread in discussion about finding a mentor that may want to work with me on my scripting abilities.
I hope this is enough or even more than you need to know to answer the question. And I apoligize if it isn’t enough. I’ll add whatever is needed to make it more understandable. Bottom line is I want to grab each player currently playing in the game when I’m there, Place their model clone(archivable) in the viewport frame when I open my gui so that I can alter their stats from there… if I’m feeling generous.