Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Why is my local camera not tweening?

Asked by 4 years ago

The tweening part is at the bottom of the whole script.

repeat wait()
    workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
until workspace.CurrentCamera.CameraType == Enum.CameraType.Scriptable
local camera = Instance.new("Part", workspace)
camera.Anchored = true
camera.CanCollide = false
camera.Transparency = 1
camera.CFrame = CFrame.new(-3.75, 4, -5.25)
camera.Orientation = Vector3.new(-5, -90, 0)
workspace.CurrentCamera.CFrame = camera.CFrame
local mouse = game.Players.LocalPlayer:GetMouse()
local cameraMovement
cameraMovement = game["Run Service"].RenderStepped:Connect(function()
    local center = Vector2.new(workspace.CurrentCamera.ViewportSize.X / 2, workspace.CurrentCamera.ViewportSize.Y / 2 - game.GuiService:GetGuiInset().Y)
    workspace.CurrentCamera.CFrame = camera.CFrame * CFrame.new(camera.CFrame.LookVector + Vector3.new((-mouse.X - center.X) / 4000, (mouse.Y - center.Y) / 4000, 0))
end)
repeat wait() until script.Continue.Value == true
cameraMovement:Disconnect()
local part = Instance.new("Part", workspace)
part.Anchored = true
part.CanCollide = false
part.BrickColor = BrickColor.White()
part.Size = Vector3.new(13, 7.25, 2)
part.CFrame = CFrame.new(16.25, 6.875, -4.5) * CFrame.Angles(0, math.rad(90), 0)
wait(1)
game.TweenService:Create(camera, TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0), {CFrame = workspace.CameraPlayDestination.CFrame}):Play() -- Over here is where it doesn't tween the camera.
wait(2)
0
My eyes are bleeding from looking at this. Please Indent your code. Tizzel40 243 — 4y
0
I do indent my code. OscarTheRobloxPlayer 32 — 4y
0
No you do not indent your code. WideSteal321 773 — 4y
0
Well, not this one besides my other scripts and stop focusing on the indentation and focus on the bottom of this script because I want someone to answer this question ASAP. OscarTheRobloxPlayer 32 — 4y

1 answer

Log in to vote
0
Answered by 4 years ago

Hey, hope you're having a great day. For others that are struggling to read the code, I might have made it easier to read.

-- Making Camera Scriptable --

repeat wait()
    workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
until workspace.CurrentCamera.CameraType == Enum.CameraType.Scriptable

-- Camera Properties --
local camera = Instance.new("Part", workspace)
camera.Anchored = true
camera.CanCollide = false
camera.Transparency = 1
camera.CFrame = CFrame.new(-3.75, 4, -5.25)
camera.Orientation = Vector3.new(-5, -90, 0)

-- Change Camera
workspace.CurrentCamera.CFrame = camera.CFrame

-- Camera Movement Determining -- 

local mouse = game.Players.LocalPlayer:GetMouse()
local cameraMovement

cameraMovement = game["Run Service"].RenderStepped:Connect(function()
    local center = Vector2.new(workspace.CurrentCamera.ViewportSize.X / 2, workspace.CurrentCamera.ViewportSize.Y / 2 - game.GuiService:GetGuiInset().Y)
    workspace.CurrentCamera.CFrame = camera.CFrame * CFrame.new(camera.CFrame.LookVector + Vector3.new((-mouse.X - center.X) / 4000, (mouse.Y - center.Y) / 4000, 0))
end)

-- Continue Value --
repeat wait() 
until script.Continue.Value == true

-- Disconect Camera Movement --
cameraMovement:Disconnect()

-- Part Properties --
local part = Instance.new("Part", workspace)
part.Anchored = true
part.CanCollide = false
part.BrickColor = BrickColor.White()
part.Size = Vector3.new(13, 7.25, 2)
part.CFrame = CFrame.new(16.25, 6.875, -4.5) * CFrame.Angles(0, math.rad(90), 0)

-- Tweening Camera --
wait(1)
game.TweenService:Create(camera, TweenInfo.new(2, Enum.EasingStyle.Sine, Enum.EasingDirection.InOut, 0), {CFrame = workspace.CameraPlayDestination.CFrame}):Play() -- Over here is where it doesn't tween the camera.
wait(2)

The issue that may be occuring here is that you need to reference TweenService like this:

game:GetService("TweenService")
0
Let me know if this is the issue! SprinkledFruit101 135 — 4y
0
No, I just checked myself and I noticed that the ":Disconnect" method on line 18 doesn't work. I fixed it and it is all good. Thank you for the attempt! OscarTheRobloxPlayer 32 — 4y
0
No problem! Glad you were able to fix the issue! SprinkledFruit101 135 — 4y
Ad

Answer this question