I am getting an error
"Part is not a valid member of Workspace “Workspace”, but it clearly is a member as shown here:
Does anyone have an explanation for this? Thanks.
I am getting an error
"Part is not a valid member of Workspace “Workspace”, but it clearly is a member as shown here:
Does anyone have an explanation for this? Thanks.
I tried that just now, and to no avail.
Remove the “game.Workspace.Part =“ part of the script and see what happens. The script thinks you are changing a property of workspace, “Part” when in reality, there is no such property.
(did not mean to reply to D0RYU)
oh I don’t even lerp at all so that’s my bad, ima delete my old reply
Yeah, this is the problem. I often run into it when using ValueObjects.
Ok I tried it, it stopped the error, but prevented the lerp from even working? It wont even do anything now
workspace
> game.Workspace
Instance
to type CFrame
(do workspace.Part.CFrame = LerpedCFrame)Can you copy-paste the code for me so I can tweak it?
Edit: You can go ahead and ignore my reply. Instead of removing “game.Workspace.Part”, just change it to “game.Workspace.Part.CFrame”
Here:
game:GetService("RunService").RenderStepped:Connect(function()
workspace.Part.CFrame:Lerp(workspace.CurrentCamera.CFrame * CFrame.new(1.5,-1,-3),0.3)
end)
game:GetService("RunService").RenderStepped:Connect(function()
workspace.Part.CFrame = CFrame:Lerp(workspace.CurrentCamera.CFrame * CFrame.new(1.5,-1,-3),0.3)
end)
“attempt to call a nil value” error from this.
Here’s the fixed version of his script:
game:GetService("RunService").RenderStepped:Connect(function()
workspace.Part.CFrame = workspace.Part.CFrame:Lerp(workspace.CurrentCamera.CFrame * CFrame.new(1.5,-1,-3),0.3)
end)
Okay, I have a question.
Why are you using a constant loop for a lerp? This isn’t how lerp should be used from my knowledge.
RunService does not run the same way while
does, if you put a loop inside of a RenderStep it will create new threads and continue processing multiple loops until each loop is solved. Lerp is something that only looks good if it’s constantly iterated with something like a for
loop. Iterating at .3
will mean it will only go the distance that is .3
between OldCFrame and NewCFrame, making lerp useless in this case, if you want it smooth you will need to configure it differently.
You’re trying to set a part to a CFrame. It needs to be game.Workspace.Part.CFrame
etc etc
This worked, thanks a lot. I appreciate it.
If I remember correctly, CFrame:Lerp() doesn’t create a loop.
It’s typically treated as such, lerps are used to add a CFrame to another CFrame, except lerps also have an argument for it’s “position” between the two CFrames, typically you’d use a for
loop that iterates like
for i = 0, 1, .05 do
part.CFrame = part.CFrame:lerp(newCFrame, i);
end;
It’s just the manual version of a Tween basically. If you’re using a lerp to just iterate once at a static value like 0.3
you should not be using lerp and instead just adding a CFrame to another CFrame, I know optimization wise it doesn’t really make a difference but it’s just better practice not treating all CFrame to CFrame operations as a lerp.
In the code there is no trace of a loop, so I don’t exactly see the problem. Sure he doesn’t have to use lerping to get what he wants but hey, if it works, it works. Remember, this is #help-and-feedback:scripting-support, not #help-and-feedback:code-review
Position is not a good nickname-in-quotes because that is an existing Vector3 property and can confuse bypassing readers. The correct term would be “alpha”.
CFrames can’t be added to other CFrames.
Oh right. A lerp is not needed here as, you could just add 0.3 of the goal CFrame.
game:GetService("RunService").RenderStepped:Connect(function()
workspace.Part.CFrame = workspace.CurrentCamera.CFrame * CFrame.new(Vector3.new(1.5,-1,-3)*0.3)
end)