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

Would this event continue indefinitely?

Asked by 7 years ago

I've created a local script in which a Camera is manipulated to view a different object, when the player clicks they're returned to viewing their character.

Would the Mouse.Button1Down:connect(ActiveCamera) event continue until the script was removed, or would it be nulled upon function completion. If it is a lasting event please give advice on how to fix it.

Code :

local RepS = game:GetService("ReplicatedStorage")
local Remote = RepS.Remote
local CameraEvent = Remote.CEvent

local Player = game.Players.LocalPlayer
local Mouse = Player:GetMouse()

CameraEvent.OnClientEvent:connect(function(Camera)
    local Cam = workspace.CurrentCamera
    local Character = workspace[Player.Name]

    Cam.CameraSubject = Camera

    local ActiveCamera = function()
        if not Character:FindFirstChild("Head") then return end
        Cam.CameraSubject = Character.Head
        return
    end

    Mouse.Button1Down:connect(ActiveCamera)
    return
end)

1 answer

Log in to vote
0
Answered by 7 years ago

I've answered the question myself.

Ad

Answer this question