hello, so pretty much what this script does is doing is just spinning a part which is above a checkpoint and it’s also hovering up and down. And when the player finally reaches it, it’ll turn invisible slowly. What I’m not really satisfied about it, it’s how long the code is and it’s also using tween a lot. I wanted to make this performance friendly so that’s the reason of adding a lot of tweens and no loops making it spin. I’ve thought of using some module scripts for this but haven’t really gotten started all I did was just made a path to the module script. I was wondering if there was a shorter way of doing this that’s also performance friendly. (local script)
local TweenService = game:GetService("TweenService")
local Checkpoint = game.ReplicatedStorage.MainSpawnables.CheckPoint
local modulescript = game.ServerScriptService:FindFirstChild("ForCheckpoints")
----------------------------------------------------------------------------------------------------------------------------------------------(RustyPipes) 1
local CloningBox = Checkpoint:Clone()
CloningBox.Parent = game.Workspace.RustyPipes
local CheckpointBox = game.Workspace.RustyPipes:FindFirstChild("CheckPoint").Box
CheckpointBox.Position = game.Workspace.RustyPipes.Position + Vector3.new(0, 5 , 0)
CheckpointBox.ColorCircle.Position = game.Workspace.RustyPipes.Position
local part = CheckpointBox
local info = TweenInfo.new(3, Enum.EasingStyle.Quad, Enum.EasingDirection.In,-1,true,0.1)
local goals = {Position = part.Position + Vector3.new(0, 0.6 , 0), Position = part.Position + Vector3.new(0, -0.8, 0);}
local movepart2 = TweenService:Create(part, info, goals)
movepart2:Play()
local info2 = TweenInfo.new(1,Enum.EasingStyle.Linear)
Spin1 = TweenService:Create(part, info2, {CFrame = part.CFrame * CFrame.Angles(math.rad(120), 0, 0)})
Spin2 = TweenService:Create(part, info2, {CFrame = part.CFrame * CFrame.Angles(math.rad(240), 0, 0)})
Spin3 = TweenService:Create(part, info2, {CFrame = part.CFrame * CFrame.Angles(math.rad(360), 0, 0)})
Spin1:Play()
Spin1.Completed:Connect(function()Spin2:Play() end)
Spin2.Completed:Connect(function()Spin3:Play() end)
Spin3.Completed:Connect(function()Spin1:Play() end)
local connection
local function BoxTouched()
connection:Disconnect()
local info = TweenInfo.new(3, Enum.EasingStyle.Sine, Enum.EasingDirection.In,0,false,0)
local goals = {Transparency = 1,Position = CheckpointBox.Position + Vector3.new(0, 7 , 0);}
local movepartT2 = TweenService:Create(CheckpointBox, info, goals)
movepartT2:Play()
CheckpointBox.checkpoint.Enabled = true
CheckpointBox.Sparkles.Enabled = true
CheckpointBox.Sound.Playing = true
CheckpointBox.ColorCircle.BrickColor = BrickColor.Black()
wait(3)
CheckpointBox.Sparkles.Enabled = false
CheckpointBox.checkpoint.Enabled = false
CheckpointBox.Sound.Playing = false
end
connection = CheckpointBox.Touched:Connect(BoxTouched)