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

Camera changed as soon as hat is worn! I want it to change when the hat is clicked?

Asked by 9 years ago

I have this script here so that when the user wears a hat, it changes to the Hat (A GoPro) perspective. However, the camera changes straight from when the hat is worn, not when I click on the Handle. How do I fix this!

wait(0.2)
local cam=workspace.CurrentCamera
local player=game.Players.LocalPlayer
local Cam = script.Parent

game:GetService("RunService").RenderStepped:connect(function()
        cam.CameraSubject=Cam.Value
        cam.CameraType=("Scriptable")
        cam.CoordinateFrame = Cam.Value:GetRenderCFrame()
        player.CameraMaxZoomDistance=0
        cam.FieldOfView = 90
end)

script.Parent.Parent.MouseButton1Click:connect(function()
cam.CameraType = ("Custom")
cam.CameraSubject=player.Character.Humanoid
player.CameraMaxZoomDistance=300
cam.FieldOfView = 70
script.Parent.Parent.Parent:Destroy()
end)

while wait() do
    if player.Character.Humanoid.Health == 0 then
        cam.CameraType = ("Custom")
cam.CameraSubject=player.Character.Humanoid
player.CameraMaxZoomDistance=300
cam.FieldOfView = 70
script.Parent.Parent.Parent:Destroy()
    end
end

This is a Local Script that is situated in the GUI that appears saying [Close GoPro].

0
Make it easier for us. Where is the Handle? Where is the hat itself? What is Cam.value? Marios2 360 — 9y

Answer this question