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

Why will Enum.CameraType.Custom not connect the camera back the player after the script is ran?

Asked by
Txeer 46
4 years ago
Edited 4 years ago

I am currently working on making a GUI reappear when a player dies and it works perfectly the first time. The second time it works fine except when I tell it to return the camera type to custom, it does make it custom but the camera isn't connected to the player. Any ideas?

Example of what I'm talking about

Script:

game.ReplicatedStorage.RemoteEvents.PlayButton.OnClientEvent:Connect(function()

local backpack = game.Players.LocalPlayer.Backpack

        local looky = game.Workspace.CurrentCamera

        if backpack:FindFirstChild("Holy Lightning Blade") then

        storage.RemoteEvents.MobileOn:FireServer()

        script.Parent.Visible = false

        repeat wait()
        looky.CameraType = Enum.CameraType.Custom
        until looky.CameraType == Enum.CameraType.Custom

            elseif backpack:FindFirstChild("Metal Blade") then

            storage.RemoteEvents.MobileOn:FireServer()

            script.Parent.Visible = false

            repeat wait()
            looky.CameraType = Enum.CameraType.Custom
            until looky.CameraType == Enum.CameraType.Custom

                elseif backpack:FindFirstChild("Starter Blade") then

                storage.RemoteEvents.MobileOn:FireServer()

                script.Parent.Visible = false

                repeat wait()
                looky.CameraType = Enum.CameraType.Custom
                until looky.CameraType == Enum.CameraType.Custom

                    elseif backpack:FindFirstChild("Starter Sword") then

                    storage.RemoteEvents.MobileOn:FireServer()

                    script.Parent.Visible = false

                    repeat wait()
                    looky.CameraType = Enum.CameraType.Custom
                    until looky.CameraType == Enum.CameraType.Custom

                        elseif backpack:FindFirstChild("Steel Sword") then

                        storage.RemoteEvents.MobileOn:FireServer()

                        script.Parent.Visible = false

                        repeat wait()
                        looky.CameraType = Enum.CameraType.Custom
                        until looky.CameraType == Enum.CameraType.Custom

                                elseif backpack:FindFirstChild("Sword") then

                                storage.RemoteEvents.MobileOn:FireServer()

                                script.Parent.Visible = false

                                repeat wait()
                                looky.CameraType = Enum.CameraType.Custom
                                until looky.CameraType == Enum.CameraType.Custom

                                    elseif backpack:FindFirstChild("Sword Of Light") then

                                    storage.RemoteEvents.MobileOn:FireServer()

                                    script.Parent.Visible = false

                                    repeat wait()
                                    looky.CameraType = Enum.CameraType.Custom
                                    until looky.CameraType == Enum.CameraType.Custom

                                        elseif backpack:FindFirstChild("Wooden Sword") then

                                        storage.RemoteEvents.MobileOn:FireServer()

                                        script.Parent.Visible = false

                                        repeat wait()
                                        looky.CameraType = Enum.CameraType.Custom
                                        until looky.CameraType == Enum.CameraType.Custom

            else
                script.Parent.Parent.NoSword.Position = UDim2.new(0.321, 0,0.321, 0)
        end
end)

(The script broke when I pasted it)

0
I don't see where you're setting the camera type back to the default one for it to lock onto the character MrLonely1221 701 — 4y
0
Look inside one of the elseif blocks, it should be towards the end where it says repeat wait() Txeer 46 — 4y
0
I couldn't remember if Roblox used Custom or a different camera type for attaching to the player. Set the CameraSubject to the player's humanoid in their character MrLonely1221 701 — 4y

1 answer

Log in to vote
0
Answered by
Txeer 46
4 years ago

Thank you MrLonely1221. I solved this by adding a block that changes the camera's subject to the player's humanoid.

repeat wait()
looky.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
until looky.CameraSubject == game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
Ad

Answer this question