Hello,
First of all, I would like to say that your explanation of the problem is quite confusing. Some people may not understand the problem if they do not take a second glance at it.
Secondly, to fix your issue, we need to have a better grasp/understanding of the problem, so I decided to do some indenting fixes to have a better look at the issue.
My logic: Indenting anything that is longer than hellohowareyoudoing or more is shortened with a new line.
workspace.tm.PrimaryPart = workspace.tm.tp
while true do
for i = 1, 250 do
wait()
workspace.tm:SetPrimaryPartCFrame(
CFrame.new(
workspace.tm.PrimaryPart.Position +
Vector3.new(0,0,-6)
)
)
end
wait(5)
for i = 1, 100 do
wait()
workspace.tm.tp.CFrame = CFrame.new(
-181.1,
0.5,
765.5
)
end
wait(.2)
end
With better formatting, I can start to see a few issues with your code.
- At line 15+, what’s with setting the CFrame of the part to a constant position 100 times? This would only lag the server for no necessary reason.
- At line 3-11, You are resetting the orientation of the part in your
CFrame.new()
block.
This is unnecessary.
Another issue I saw is that you are adding to the Primary part’s position with a Vector3, which is probably the issue you are currently facing. This is a simple fix, as so:
for i = 1, 250 do
wait()
workspace.tm:SetPrimaryPartCFrame(
workspace.tm:GetPrimaryPartCFrame() *
CFrame.new(0, 0, -6)
)
end
- At line 1, you are setting the PrimaryPart of the object. This is unnecessary, since you are able to set it using ROBLOX’s properties menu, as such:
![image](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/4X/b/e/0/be0b2bf747d8dbe16de7f47a2c98abc5f968c6c6.png)
![image](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/4X/1/b/8/1b8db5ad848d3f530340cb16ee8e1e7cdf6854b6.png)
Simple fix without reinventing the wheel.
With these fixes in mind, you should have your problem solved.
Some other tips:
Due to floating point and other stuff with the for loop, I’d suggest storing the PrimaryPart’s CFrame before hand, so you can easily multiply it and revert back to it after your loop.
Something like this:
local Model = workspace:WaitForChild("tm") -- I like using WaitForChild, you don't exactly *need* to.
local OriginalCFrame = Model:GetPrimaryPartCFrame()
while true do
for i = 1, 250 do
wait()
Model:SetPrimaryPartCFrame(
OriginalCFrame *
CFrame.new(0, 0, -6 * i)
)
end
wait(5)
Model:SetPrimaryPartCFrame(OriginalCFrame)
wait(.2)
end
This way, there’s not much of an issue with floating point, and you aren’t setting some extremely precise position for it to go to (which will be weird if you move the model to a different position).
If there’s any issues with my solution, just reply to my comment. ![:wink: :wink:](//devforum-uploads.s3.dualstack.us-east-2.amazonaws.com/uploads/original/3X/8/e/8ec9317d6d952b271c47f40b20836ea392bef673.png?v=12)