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

Camera tweening won't work at all, no errors in output. Why?

Asked by 4 years ago
Edited 4 years ago

I am trying to make it so when this cannon script runs, 1 of the things that happens is your camera moves its location with tweening. Interpolate wouldn't work at all, and it is discouraged. Any idea how I can fix this script?

01local Workspace = game:GetService("Workspace")
02local UserInputService = game:GetService("UserInputService")
03local PlayerName = script.Parent.Parent.Parent.Name
04local Character = Workspace[PlayerName]
05local Cannon = Workspace.Cannon
06 
07UserInputService.InputBegan:Connect(function(input)
08    if input.KeyCode == Enum.KeyCode.E then
09        for i, v in pairs(Character:GetDescendants()) do
10            v.Anchored = true
11        end
12-- Code below here is setting up the camera
13        local cam = workspace.CurrentCamera
14        local TweenService = game:GetService("TweenService")
15        local tweenInfo = TweenInfo.new(
View all 29 lines...

There are no issues with the code running in the first place, it just won't work.

1 answer

Log in to vote
1
Answered by
SteamG00B 1633 Moderation Voter
4 years ago
Edited 4 years ago

The order of arguments in a function does matter. What you did was create the tween with the arguments in backwards order, and as I've never done that before, I am not sure why it didn't give you an error, but this is how you fix it on line 25:

1local Tween = TweenService:Create(cam, tweenInfo, tweenProperties)

EDIT:

Alright, there is one thing that you should change because it's simply a bad practice, and one reason why I believe it is not working how you want it to.

First one, don't name UserInputService USI. If your goal was to use an acronym, your letters should be in order, so you should get into the habit of making your code easy to follow just in case you decide to join or make your own dev team later on.

Second one, your CFrame goal is starting at a position and looking towards another position that is made up of your parts orientation. That won't work, but unless that's what you wanted it to do, then I don't know why else it wouldn't work.

0
@cookie_more Notice the order of parameters in the tool-tip as you type and at https://developer.roblox.com/en-us/api-reference/function/TweenService/Create AlexTheCreator 461 — 4y
0
It didn't change anything. Your definitely right, but it still isn't working. cookie_more 30 — 4y
0
Made an edit. SteamG00B 1633 — 4y
0
Just making a comment to remind you that your question is still unanswered. Does it work or not? SteamG00B 1633 — 4y
Ad

Answer this question