Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

Any way to remove CFrame.fromEulerAnglesXYZ lag?

I made spinner that if its touched, then it would teleport the player back to where they started (like an obby). But when I was testing it when friends, it would lag. Here's the script:

local teleportpart = script.Parent --the part

while true do --the loop
 script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,0.102,0)
	teleportpart.Touched:Connect(function(hit) --function when player touches part
	    if hit.Parent:WaitForChild("HumanoidRootPart") then
	        game.Players[tostring(hit.Parent.Name)].Character:SetPrimaryPartCFrame(CFrame.new(228.5,24.5,880)) --where it teleports the player
	    end
	end)
 wait()
end

Any help would be appreciated!

1 comment

0

To answer your question before, the while loop runs at longer intervals (meaning less threads) and just interpolates the cframes with TweenService.

1 answer

✓ Accepted answer

You can try tweening the CFrame to greater increments.

local teleportpart = script.Parent --the part
local ts = game:GetService("TweenService")
local timetaken = .1 -- Change this to control speed

while wait(timetaken) do
local goal = {}
 goal.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ(0,1.02,0) -- Increment is ten times larger; you can change this to any denomination you like.
local ti = TweenInfo.new(timetaken, Enum.EasingStyle.Linear)
local tween = ts:Create(script.Parent, ti, goal)
tween:Play()
    teleportpart.Touched:Connect(function(hit)
        if hit.Parent:WaitForChild("HumanoidRootPart") then
            game.Players[tostring(hit.Parent.Name)].Character:SetPrimaryPartCFrame(CFrame.new(228.5,24.5,880)) --where it teleports the player
        end
    end)
end

1 comment

0

Thank you so much! Sorry to ask but would you kindly explain how this works? Im just the guy that says this so i can understand the code, sorry.

This discussion is preserved as it was. New answers, comments, and votes are closed.