cool i did not know a thing breaks by it self and fixes by itself xd
Set the ImageColor3
to 255, 255, 255 and ImageTransparency
to 0, and instead change the BackgroundColor3
and BackgroundTransparency
of the frame
don’t you think the white part will not be visible in white background or black part will be not visible in black background?
oh it worked! thank you!
so it works with certain colors only? please tell me what colors can it work and what colors can it break
Your image color is 0,0,0 which makes both the background and the part inside the viewport completely black. Like I said, if you only want to change the background color of the frame, e.g. white to black, then change the BackgroundColor3
of the viewport frame
but i checked in player > gui > viewport frame
the part is not there
i am sure roblox don’t have this kind of bug, they don’t make things work sometimes and not work sometimes so i think the script broke or the viewport broke
Hello everyone,
So I tried to change it but turns out the part is hiding.
I want it like a shop gui and like many games where the model will be rotating 360 degrees
the part don’t turn either
the script:
local part = Instance.new("Part",script.Parent.ViewportFrame)
part.Size = Vector3.new(4,4,4)
local vpf = script.Parent.ViewportFrame
local runservice = game:GetService("RunService")
local cam = Instance.new("Camera",vpf)
vpf.CurrentCamera = cam
local rotation = 0
local newcframeforcam = part.CFrame + Vector3.new(5,5,5)
local newcframeforcam2 = CFrame.lookAt(cam.CFrame.Position,part.Position)
runservice.RenderStepped:Connect(function()
cam.CFrame = newcframeforcam
part.Orientation = Vector3.new(0,5,0)
cam.CFrame = newcframeforcam
vpf.CurrentCamera = cam
end)
while wait(0.25) do
rotation = rotation + 5
end
tried to change script then this happend:
its like a frozen tiny thing which don’t move either can be seen easily
script 2:
local part = Instance.new("Part",script.Parent.ViewportFrame)
part.Size = Vector3.new(4,4,4)
local vpf = script.Parent.ViewportFrame
local runservice = game:GetService("RunService")
local cam = Instance.new("Camera",vpf)
vpf.CurrentCamera = cam
part.Material = Enum.Material.SmoothPlastic
part.BrickColor = BrickColor.Random()
local rotation = 0
local newcframeforcam = part.CFrame + Vector3.new(3,3,3)
local newcframeforcam2 = CFrame.lookAt(cam.CFrame.Position,part.Position)
while wait(2) do
rotation = rotation
end
runservice.RenderStepped:Connect(function()
cam.CFrame = newcframeforcam
part.CFrame = part.CFrame * CFrame.Angles(0,math.deg(rotation),0)
cam.CFrame = newcframeforcam
vpf.CurrentCamera = cam
end)
There is some issue with your structural code and the order it execute in.
You have all of your setup at the top which is good.
Then you have a while loop that doesn’t end, which prevents it from reaching the RenderStepped. Also your rotate = rotate is not incrementing anything.
You can simply the code by setting up your viewportFrame and how the object would display first. Once you’re happy with the it as a stationary object.
You can use Tween service inside of the while loop to rotate using simple Orientation.
yes its good as a stationary object but when u tween it, this happens:
you see this, the camera will go somewhere and not be visible
Note: No error is printed either pcall function is not printing any error
What is the position of your Part?
and what is the position of your Camera?
local part = Instance.new("Part",script.Parent.ViewportFrame)
part.Size = Vector3.new(4,4,4)
local vpf = script.Parent.ViewportFrame
local runservice = game:GetService("RunService")
local cam = Instance.new("Camera",vpf)
vpf.CurrentCamera = cam
part.Material = Enum.Material.SmoothPlastic
part.BrickColor = BrickColor.Random()
local rotation = 0
local newcframeforcam = part.CFrame + Vector3.new(3,3,3)
local newcframeforcam2 = CFrame.lookAt(cam.CFrame.Position,part.Position)
idk the position of the part
the position of cam is front of part
You’ll need to set the Part’s position to [0, 0, 0]
Because the viewportFrame is an actual 3D space and you want to keep it at [0, 0, 0] because the part doesn’t need to move.
Then you fix the camera onto the object.
I think you’re making it overcomplicated. You don’t need CFrames or anything
local runservice = game:GetService("RunService")
local vpf = script.Parent.ViewportFrame
local part = Instance.new("Part")
part.Parent = script.Parent.ViewportFrame
part.Size = Vector3.new(10,10,10) -- set the size to your desired scale
local cam = Instance.new("Camera",vpf)
vpf.CurrentCamera = cam
runservice.RenderStepped:Connect(function()
part.Orientation += Vector3.new(0,5,0)
vpf.CurrentCamera = cam
end)
this is what i did at first, why it did not work, and where did u keep the camera position in viewport frame?
I didn’t set the viewport camera CFrame at all, it is left unedited.
Want a place file for it?
Sure sorry for late reply my pc broke
the object should be inside the viewportframe object, set the CurrentCamera property in the viewportframe object to the camera you’ve made
Assuming the reason why it’s not working is that it depends on where the position of the part is at, I have modified the old code I got and that fixes it, I made it so the camera follows the part’s position so you don’t have to set the part’s position to 0.
Code
local runservice = game:GetService("RunService")
local vpf = script.Parent.ViewportFrame
local OFFSET = Vector3.new(0,15,15)
local part = Instance.new("Part")
part.Position = Vector3.new(0,110,0)
part.Size = Vector3.new(10,10,10)
part.Parent = script.Parent.ViewportFrame
local vpfCam = Instance.new("Camera")
vpf.CurrentCamera = vpfCam
vpfCam.Parent = vpf
vpfCam.CFrame = CFrame.new(part.Position+OFFSET,part.Position)
runservice.RenderStepped:Connect(function()
vpfCam.CFrame = CFrame.new(part.Position+OFFSET,part.Position)
part.Orientation += Vector3.new(0,5,0)
end)
Placefile
im pro.rbxl (30.6 KB)
Also includes a Video/Gif.
oh alright thank you for it my pc sucks so its so laggy, i threw it away xd