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

Help with cameras?

Asked by 9 years ago

Im trying to make this touched function that changes the player cameratype to "Watch" Can somebody help me?

function cam(part)
if part.Parent:findFirstChild("Humanoid") then
print("Works")
camclone = game.Workspace.CurrentCamera:clone()
camclone.Parent = (part.Parent.Backpack)
camclone.CameraType = "Watch"
end
end
script.Parent.Touched:connect(cam)

1 answer

Log in to vote
1
Answered by
hiccup111 231 Moderation Voter
9 years ago

You can only access the player's camera via LocalScripts, try this:

--LocalScript in backpack perhaps

local player = game.Players.LocalPlayer
local character = player.Character
local camera = Workspace.CurrentCamera

camera.CameraType = "Custom" -- Need to reset the camera every time the player respawns.

character["Left Leg"].Touched:connect(function(obj)

    if obj == Workspace.Part then -- whatever you need to touch

        camera.CameraType = "Watch"

    end

end)

Ad

Answer this question