Hey Everyone,
I’m using viewports for my story game for the shop to make the items spin. However it is not working correctly. The camera is supposed to rotate around the object like daycare [story]. I made it very similar to daycare story as I liked the design and how it rotated. This is what it should look like:
https://gyazo.com/783452b91beea5f74c7b328196bc90fe
This is what mine looks like: https://gyazo.com/02a89c8c768cf30f153476e64a40365e
I’m not sure what the issue is.
Here is my script:
Gamepass = game.ReplicatedStorage.Gamepasses:GetChildren()
Info = script.Parent.Parent.Info
for v1, v2 in pairs(Gamepass) do
spawn(function()
local v3 = script:WaitForChild("ImageButton"):Clone()
v3.Name = v2.Name
v3.Parent = script.Parent
if v2.ID.Value >= 825252 then
v3.ImageColor3 = BrickColor.new("Gold").Color
elseif v2.ID.Value == 7835225 then
v3.ImageColor3 = BrickColor.new("Bright red").Color
elseif v2.ID.Value >= 772235543 then
v3.ImageColor3 = BrickColor.new("Gold").Color
end;
local v4 = v2.Handle:Clone()
v4.Position = Vector3.new(0, 0, 0)
v4.Parent = v3.ViewportFrame
local v5 = Instance.new("Camera", v3.ViewportFrame)
v5.CameraType = Enum.CameraType.Scriptable
v5.CFrame = CFrame.new(-1.25, 0, 0, -0, -0, -1, -0, 1, -0, 1, 0, -0)
v3.ViewportFrame.CurrentCamera = v5
v5.FieldOfView = v2.FOV.Value
local function v6()
if Info.ViewportFrame:FindFirstChild(v3.Name) == nil then
Info.ViewportFrame:ClearAllChildren()
Info.Buy.Visible = true
Info.Viewing.Value = v3.Name
local v7 = v2.Handle:Clone()
v7.Name = v3.Name
v7.Position = Vector3.new(0, 0, 0)
v7.Parent = Info.ViewportFrame
spawn(function()
local v8 = Instance.new("Camera", Info.ViewportFrame)
v8.FieldOfView = v2.FOV.Value
v8.CameraType = Enum.CameraType.Scriptable
v8.CFrame = CFrame.new(0, 0, 0, -0, -0, -1, -0, 1, -0, 1, 0, -0)
Info.ViewportFrame.CurrentCamera = v8
local v9 = 0
while v7 ~= nil do
v8.CoordinateFrame = CFrame.new(v7.Position) * CFrame.Angles(0, v9, 0) * CFrame.new(0, 0, 5)
v9 = v9 + math.rad(1)
wait()
end
end)
end
end
v3.MouseEnter:Connect(v6)
v3.SelectionGained:Connect(v6)
local v10 = 0
while wait() do
v5.CoordinateFrame = CFrame.new(v4.Position) * CFrame.Angles(0, v10, 0) * CFrame.new(0, 0, 5)
v10 = v10 + math.rad(1)
end
end)
end
while true do
script.Parent.CanvasSize = UDim2.new(0, 0, 0, script.Parent.UIGridLayout.AbsoluteContentSize.Y)
wait()
end
It’s a local script.
Thanks for any help! There are no errors.