Hey there,
I’ve spent a very long time trying to fix a bug relating to the camera, but everything I’ve tried is simply not working.
Basically the code works as follows:
- While the menu is visible, the camera is set to scriptable and it’s CFrame is set to a part.
- Once the player presses the “DEPLOY” button the players camera gets set to custom.
The issue here is, it only works once then it gets into this weird position. (Video of the bug is attached at the bottom.)
I’ve tried the following:
- Manually setting the player’s camera CFrame to it’s head, that didn’t work sadly.
Here is the code:
local Player = game.Players.LocalPlayer
local StarterGui = game:GetService("StarterGui")
local Character = Player.Character
wait(0.01)
workspace.CurrentCamera.CameraType = Enum.CameraType.Scriptable
workspace.CurrentCamera.CFrame = workspace:WaitForChild("CameraPart").CFrame
local StarterGui = game:GetService("StarterGui")
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.PlayerList, false)
script.Parent.MouseButton1Click:Connect(function()
if Player.Team == game.Teams.Loading then
script.Parent.Parent.Parent.Parent.Parent.ActionUI:WaitForChild("message"):WaitForChild("WarningLabel").Visible = true
wait(2.5)
script.Parent.Parent.Parent.Parent.Parent.ActionUI:WaitForChild("message"):WaitForChild("WarningLabel").Visible = false
elseif Player.Team == game.Teams.Republic then
local StarterGui = game:GetService("StarterGui")
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("MorphPlayerEventRep"):FireServer(Player)
script.Parent.Parent.Parent.Parent.Visible = false
--StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
script.Parent.Parent.Parent.Parent.Parent.ActionUI.Frame.people.Visible = true
script.Parent.Parent.Parent.Parent.Parent.ActionUI.Frame.people2.Visible = true
game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("SpawnPlayerEvent"):FireServer(Player)
script.Parent.Parent.Parent.Parent.Visible = false
elseif Player.Team == game.Teams.CIS then
local StarterGui = game:GetService("StarterGui")
workspace.CurrentCamera.CameraType = Enum.CameraType.Custom
script.Parent.Parent.Parent.Parent.Parent.ActionUI.Visible = true
StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, true)
game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("MorphPlayerEventCIS"):FireServer(Player)
script.Parent.Parent.Parent.Parent.Parent.ActionUI.Frame.people.Visible = true
script.Parent.Parent.Parent.Parent.Parent.ActionUI.Frame.people2.Visible = true
--StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
game.ReplicatedStorage:WaitForChild("Remotes"):WaitForChild("SpawnPlayerEvent"):FireServer(Player)
script.Parent.Parent.Parent.Parent.Visible = false
else
warn("PLAYER IS NOT ON A TEAM YET!")
end
end)
Thank you for your time.