Hi. If you’ve checked my topics, you know I’m currently having a lag issue. It has been reduced slightly… but it still ruins the game a lot. So… I’m in need of some help.
-
What do you want to achieve? The best moving method for parts.
-
What is the issue? for loop causes lag when moving parts using CFrame and the now deprecated function, wait().
-
What solutions have you tried so far? Moving parts using CFrame and TweenService.
CFrame script I used previously, which caused game to lag:
local Debris = game:GetService("Debris")
local Part = script.Parent
for i = 1, 250 do
Part.CFrame = Part.CFrame * CFrame.new(0, 0, 6)
wait()
end
Debris:AddItem(Part, 0)
The TweenService script that I am currently using now… that has reduced the lag a little, but for some reason also moves diagonally instead of straight:
local Speed = script.Speed -- (The value is 30.)
local TweenService = game:GetService("TweenService")
Tentacle = script.Parent
Tweens = TweenInfo.new(
Speed.Value, -- Speed (Again, the value is 30.)
Enum.EasingStyle.Linear, -- The part moving animation. (EASING STYLE)
Enum.EasingDirection.Out, -- What direction it moves in. (EASING DIRECTION)
0, -- How many times it loops. (REPEAT COUNT)
false, -- (REVERSES)
0 -- Delays before repeating itself... but if you have repeat count set to 0.. then..
)
local Animator = TweenService:Create(Tentacle, Tweens, {Position = Tentacle.Position+Vector3.new(0, 0, 1250)})
Animator:Play()
task.wait(18)
script.Parent.Parent:Destroy()
I have recieved the suggestion to change it to RunService, which I have not tried yet. Is this the best movement method for my parts? Or just another lag causing script? Please give me some reliable answers, and please don’t argue, that confuses me more.