You can write your topic however you want, but you need to answer these questions:
- **What do you want to achieve?
I want to achieve so when the player clicks the GUI button their camera goes back to there player.
- **What is the issue?
When the player clicks the button nothing happens no output.
-
What solutions have you tried so far? Did you look for solutions on the Developer Hub?
I have tried many different ways and checked on the developer hub to see if there are any fixes. Here are the scripts both in the GUI button and the Starterplayerscripts.
local Camera = workspace.CurrentCamera
script.Parent.MouseButton1Click:connect(function()
Camera.CameraType = Enum.CameraType.Custom
end)
local Camera = workspace.CurrentCamera
wait(1)
Camera.CameraType = Enum.CameraType.Scriptable
Camera.CFrame = workspace.Lobby.LobbyCam.CFrame
Hi, try to change CameraSubject to Humanoid of player character.
local Players=game:GetService("Players")
local Camera = workspace.CurrentCamera
local player=game.Players.LocalPlayer
script.Parent.MouseButton1Click:connect(function()
if player.Character~=nil and player.Character:FindFirstChild("Humanoid") then
Camera.CameraType = Enum.CameraType.Custom
Camera.CameraSubject = player.Character.Humanoid
end
end)
The script does nothing still not even output.
Usually it takes a bit to set the CurrentCamera
to the Camera, so you might want to put a small wait in there. Try this code:
wait(1)
local Camera = workspace.CurrentCamera
script.Parent.MouseButton1Click:connect(function()
Camera.CameraType = Enum.CameraType.Custom
Camera.CameraSubject = game.Players.LocalPlayer.Character.Humanoid
Camera.CFrame = game.Players.LocalPlayer.Character.Head.CFrame
end)
EDIT: Also, make sure both of the scripts are LocalScripts
.
1 Like
I found the fix it would be to move the gui to startergui and then set adornee to the brick.