Now I’m trying to put local player model to viewport frame. Also how can I adjust camera and play animation.
Thank for reading
Now I’m trying to put local player model to viewport frame. Also how can I adjust camera and play animation.
Thank for reading
do you mean the player’s character?
I mean get player model and put it in viewport frame.
You could clone your Character, create a WorldModel inside the ViewPortFrame, put the Character in the WorldModel , set the ViewPortFrame’s CurrentCamera and set its CFrame relative to the Character in viewport then play the animation on the Animator of the Character.
You might have to update it frequently to if you want to visualize tools and stuffs.
that’s the player’s character
just clone the player’s character then set the parent
player.Character:Clone.Parent = ViewportFrame
local viewportFrame = script.Parent.viewport.WorldModel
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
local model = character:Clone()
model.Parent = viewportFrame --Error
Im trying but it error can you help me correct it please
the model’s archivable property should be set to true.
now it error on the first line.
Please give more context , whats the error?
not the first line my wrong but it error on archivable line
model.Archivable = true
here is error
Players.arch_ocean.PlayerGui.StarterGui.start.Frame.LocalScript:7: attempt to index nil with 'Archivable'
you are supposed to change the Character’s Archivable to true, then clone it.
local viewportFrame = script.Parent.avatar.WorldModel
local player = game.Players.LocalPlayer
local character = player.Character or player.CharacterAdded:wait()
character.Archivable = true
local model = character:Clone()
model.Parent = viewportFrame
local viewportCamera = Instance.new("Camera")
viewportFrame.Parent.CurrentCamera = viewportCamera
viewportCamera.Parent = viewportFrame
viewportCamera.CFrame = CFrame.new(Vector3.new(0, 2, 5))
there is no error now but the model isn’t show
If the model/part Archivable property set to false, it won’t let you clone the model/part. If it’s set to true, you’re allowed to clone the model/part.
(If the model’s Archivable property is set to true it will apply to everything in the model.)
Also it clone only model not all children
Add a wait before cloning also for the CFrame do CFrame.lookAt(model.PrimaryPart.Position + Vector3.new(0,2,-5),model.PrimaryPart.Position)
Feel free to change the offset based on ur desire
This module could be of use
just do
local AvatarViewportModule = require(.AvatarModule) -- require the module
AvatarViewportModule:Create(LocalPlayer, ViewportFrame)
Can you also drag the model inside it?
And also, do I need to place this inside a viewport frame?
I tested your module and it seems that it only displays the players HeadShot
, I recommend using RunService.RenderStepped
to automatically update the frame every second.
Here is the script that I’m using:
local vpf = script.Parent:WaitForChild("Your ViewportFrame")
local char = game.Players.LocalPlayer.Character or game.Players.LocalPlayer.CharacterAdded:Wait()
char.Archivable = true
local cam = Instance.new("Camera")
cam.Parent = vpf
vpf.CurrentCamera = cam
local clonedChar
game:GetService("RunService").RenderStepped:Connect(function()
if clonedChar then clonedChar:Destroy() end
clonedChar = char:Clone()
local hrp = clonedChar:WaitForChild("UpperTorso")
cam.CFrame = CFrame.new(hrp.Position + (hrp.CFrame.LookVector * 6), hrp.Position)
clonedChar.Parent = vpf
end)
I want the model inside in it to be draggable, is there any way to do it?
No you’d have to find the mouse position current to the viewport frame and then move it according to the position
Not really no just referance it correctly
also why would I need to update it every second