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:
01 | local teleportpart = script.Parent --the part |
02 |
03 | while true do --the loop |
04 | script.Parent.CFrame = script.Parent.CFrame * CFrame.fromEulerAnglesXYZ( 0 , 0.102 , 0 ) |
05 | teleportpart.Touched:Connect( function (hit) --function when player touches part |
06 | if hit.Parent:WaitForChild( "HumanoidRootPart" ) then |
07 | game.Players [ tostring (hit.Parent.Name) ] .Character:SetPrimaryPartCFrame(CFrame.new( 228.5 , 24.5 , 880 )) --where it teleports the player |
08 | end |
09 | end ) |
10 | wait() |
11 | end |
Any help would be appreciated!
You can try tweening the CFrame to greater increments.
01 | local teleportpart = script.Parent --the part |
02 | local ts = game:GetService( "TweenService" ) |
03 | local timetaken = . 1 -- Change this to control speed |
04 |
05 | while wait(timetaken) do |
06 | local goal = { } |
07 | 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. |
08 | local ti = TweenInfo.new(timetaken, Enum.EasingStyle.Linear) |
09 | local tween = ts:Create(script.Parent, ti, goal) |
10 | tween:Play() |
11 | teleportpart.Touched:Connect( function (hit) |
12 | if hit.Parent:WaitForChild( "HumanoidRootPart" ) then |
13 | game.Players [ tostring (hit.Parent.Name) ] .Character:SetPrimaryPartCFrame(CFrame.new( 228.5 , 24.5 , 880 )) --where it teleports the player |
14 | end |
15 | end ) |
16 | end |