Ad
Still have questions? Join our Discord server and get real time help.
Log in to vote
0

CFrame script not working as expected?

Asked by
iivSnooxy 215 Moderation Voter
7 days ago

Hello, why is my CFrame script not working as I thought it should I hope someone Can help me?

game.Workspace.Kook.CFrame = game.Workspace.Kookin.CFrame.lerp(game.Workspace.Kookina.CFrame, 0.4)
1
It’s :Lerp not .lerp DarkDanny04 376 — 7d
0
What do you want to do TTChaos 200 — 7d
0
Dark Danny it’s “:” or?.. iivSnooxy 215 — 7d
0
It's :Lerp TTChaos 200 — 7d

1 answer

Log in to vote
0
Answered by
TTChaos 200 Moderation Voter
7 days ago
Edited 7 days ago

If you want your Kook part to gradually move toward Kookin, then try the code below

local Kook = workspace.Kook -- Define Kook, I usually like defining variables
local Kookin = workspace.Kookin -- Instead of game.Workspace, I prefer workspace

local StartCFrame = Kook.CFrame -- This only works if Kook is a Part
local EndCFrame = Kookin.CFrame
local Step = 0.01 -- Default
local Time = 1 -- 1 Second

for Time = 0, 1, Step do -- Loop variable "Time" from 0 to 1 with step 0.01
    Kook.CFrame = StartCFrame:Lerp(EndCFrame, Time) -- Lerp function
    wait(Step*Time)
end

You can change Step to be anything, as long as it is

  1. Under 1

  2. Over 0

  3. 1├ĚStep is a whole number

0
Is this going to make it move smoothly, or... either way I’ll accept it! iivSnooxy 215 — 7d
0
Just so you know, the second argument to Lerp is not the time it takes for it to do the Lerp. It is the amount it goes to the end goal’s cframe. So, .5 would be halfway to the end goal’s cframe DarkDanny04 376 — 7d
0
It will move smoothly, please see the "Step changing". Lower step = more lag but smoother TTChaos 200 — 7d
0
I wish I knew more about CFrames.. iivSnooxy 215 — 7d
Ad

Answer this question