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

They have no wait in here?

This script makes it spin around a part named "FocusHere". After about 15 seconds it stops and camera is normal.. I dont get it because they have no wait in here. I would like for it to wait (5) before going back to character.

DO THIS:

  1. Make a part in Workspace named "FocusHere"
  2. Put this script in Workspace and name is "onPlayerAdded":
ServerStorage = game:GetService("ServerStorage")

game.Players.PlayerAdded:connect(function(player)
	
	local cameraScript = ServerStorage.CameraScript:Clone()
	player:WaitForChild("Backpack")
	cameraScript.Parent = player.Backpack
	cameraScript.Disabled = false
	
end)
  1. In ServerStorage make a localscript and name it "CameraScript": Local script below..
player = game.Players.LocalPlayer
cam =  game.Workspace.CurrentCamera

cam.CameraSubject = game.Workspace.FocusHere
cam.CameraType = "Custom"

loops = 0
angle = 0
position = 0

while loops <500 do
	cam.CoordinateFrame = game.Workspace.FocusHere.CFrame * CFrame.Angles(0,angle,angle) * CFrame.new(position, position, position)
	
	loops = loops + 1
	angle = angle + math.rad(3)
	position = position + 1
	wait()
end


cam.CameraSubject = player.Character.Humanoid

cam.CameraType = "Follow"

script:Destroy()

1 answer

✓ Accepted answer

Your problem is here:

while loops < 500 do

This loop will continue to run while "loops" is under 500. With each time the loop is ran though, "loops" gets increased by 1.

loops = loops + 1

Read about how while loops work here.

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