So I legit have no idea what i am doing BUT. Let me try to explain. I'm trying to do it so that when a person clicks on a gui it should focus on a tool, whether it's in another players backpack or in the workspace.
script.Parent.MouseButton1Click:Connect(function(player) if game.Players.LocalPlayer.Backpack:FindFirstChild("Tool") or workspace:WaitForChild("Tool") then local cam = workspace.CurrentCamera cam.CameraSubject = game.Players.LocalPlayer.Backpack:FindFirstChild("Tool") or workspace:WaitForChild("Tool") cam.CameraType = "Follow" end end)
here is what i tried xd
script.Parent.MouseButton1Click:Connect(function(player) 2 if game.Players.LocalPlayer.Backpack:FindFirstChild("Tool") or workspace:WaitForChild("Tool") then 3 local cam = workspace.CurrentCamera 4 cam.CameraSubject = game.Players.LocalPlayer.Backpack:FindFirstChild("Tool") or workspace:WaitForChild("Tool") 5 cam.CameraType = "Follow" 6 end 7 end)
I think that I have found your problem, It is because you putted two ends, you putted one at the 6 and one at the 7 maybe try to remove the 6 but put the 7 at th six example:
script.Parent.MouseButton1Click:Connect(function(player) 2 if game.Players.LocalPlayer.Backpack:FindFirstChild("Tool") or workspace:WaitForChild("Tool") then 3 local cam = workspace.CurrentCamera 4 cam.CameraSubject = game.Players.LocalPlayer.Backpack:FindFirstChild("Tool") or workspace:WaitForChild("Tool") 5 cam.CameraType = "Follow" 6 end)
CameraSubject
property only accepts Instance
s of the classes Humanoid
and PVInstance
, and inheritors of said classes. So things like Model
s and BasePart
s can be the value for the CameraSubject
property. Luckily, Tool
s need a Handle
BasePart
, if your tool requires it. So simply set the CameraSubject
to the Handle
of the tool.local client = game.Players.LocalPlayer local cam = workspace.CurrentCamera local character = client.Character -- Don't repeat yourself! Have a variable for the player, character and camera. script.Parent.Activated:Connect(function() -- MouseButton1Click passes no player! Use Activated instead though. if client.Character:FindFirstChild("Tool") or workspace:FindFirstChild("Tool") then cam.CameraSubject = client.Character:FindFirstChild("Tool").Handle or workspace:FindFirstChild("Tool").Handle cam.CameraType = Enum.CameraType.Follow end end)
Tool
in the character instead of the backpack, as it would not show if it was in the backpack.