Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

They have no wait in here?

Asked by
FiredDusk 1466 Moderation Voter
9 years ago

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

Log in to vote
1
Answered by
Validark 1580 Snack Break Moderation Voter
9 years ago

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.

Ad

Answer this question