Hello,
So I have a script here and as you can see I have some cframe in it. Right now, it's doing two diffrent Cframes. How it's working is it's moving one, waiting for it to finish and then move on to the next line. I want it so that it does not wait to for the first cframe to finish and just go to the second. Thanks, Anthony
local Epic=script.Parent.ClickDetector function onClick() for i = 0, 17.5, 0.2 do game.Workspace.Kitchen:SetPrimaryPartCFrame(game.Workspace.Kitchen:GetPrimaryPartCFrame() + Vector3.new(0.2,0,0)) wait() end for i = 0, 10, 0.2 do game.Workspace.Lights:SetPrimaryPartCFrame(game.Workspace.Lights:GetPrimaryPartCFrame() + Vector3.new(0,.8,0)) wait() end
Ok, so I would recommend you use Lerp(). Ill give you an example I think should help!
Start:Lerp(End,increment)
returns a position between Start and End. Increment is between 0-1 so increment of 0.5 would be halfway, 1 would be the end, 0 would be the start.
local Epic=script.Parent.ClickDetector function onClick() local StartPos = game.Workspace.Kitchen.PrimaryPart.CFrame local EndPos = StartPos + Vector3.new(35,16,0) for i = 0,1, 0.1 do wait() game.Workspace.Kitchen:SetPrimartPartCFrame(StartPos:lerp(EndPos, i) end end
Use a spawn
function. It makes the function that you "spawned" run in a then moves on to the then moves on to the next line instantly after. So you will need something like:
local Epic=script.Parent.ClickDetector function onClick() for i = 0, 17.5, 0.2 do game.Workspace.Kitchen:SetPrimaryPartCFrame(game.Workspace.Kitchen:GetPrimaryPartCFrame() + Vector3.new(0.2,0,0)) wait() end spawn(onClick) -- Im not sure if thats right if its now just search it on youtube for i = 0, 10, 0.2 do game.Workspace.Lights:SetPrimaryPartCFrame(game.Workspace.Lights:GetPrimaryPartCFrame() + Vector3.new(0,.8,0)) wait() end