i made a script to change CFrames of Attachments per second and it works perfectly but when i want it to reset its Cframe after using task.wait, it does not work…
local nyc = game.Workspace.roofbeams:WaitForChild("nycbeam")
local attachment = nyc:WaitForChild("Attachment2")
while true do
local deltaTime = game:GetService("RunService").Heartbeat:Wait()
attachment.WorldCFrame += Vector3.new(0, 0, deltaTime * 0.1)
task.wait(20)
attachment.CFrame = CFrame.new(0, 0, -78.758)
end
Are you sure its the task.wait? Because on the line where you try to set the CFrame of the attachment it is using the cframe of the attachment not WorldCFrame.
u were absolutely right but even after i used attachment.WorldCFrame *= CFrame.new(0, 0, deltaTime * 0.1) it failed to change the CFrame after task.wait
What you’re doing is, you’re setting it back to the original CFrame Everytime.
I would suggest you to do something like the following if you want it to constantly move
while true do
local deltaTime = game:GetService("RunService").Heartbeat:Wait()
attachment.CFrame += Vector3.new(0, 0, deltaTime * 0.1)
task.wait(2)
attachment.CFrame = attachment.CFrame * CFrame.new(0, 0, -78.758)
end
local TweenService = game:GetService("TweenService")
local nyc = game.Workspace:WaitForChild("nycbeam")
local attachment = nyc:WaitForChild("Attachment2")
while true do
local MoveAttachmentTween = TweenService:Create(attachment, TweenInfo.new(2,Enum.EasingStyle.Linear, Enum.EasingDirection.InOut, 0, false), {CFrame = attachment.CFrame * CFrame.new(0, 0, -78.758)})
MoveAttachmentTween:Play()
task.wait(2)
end
that almost worked but the attachment increment starts to go on an opposite direction , i want it to increase and stop and then repeat the same at a single area only