I made a loading screen but once you click play the camera doesn’t reset properly, but only sometimes. Sometimes it works perfectly and sometimes it doesn’t.
It worked a couple times but then it broke as well.
But maybe a different script is the reason for that. I have a script which automatically resets the player when joining, while he is in the scriptable camera mode. Maybe this breaks it?
local TeamChecker = script.Parent
local event = game:GetService("ReplicatedStorage").RemoteEvent
TeamChecker.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild("Humanoid") then
print("touched works")
local Tycoons = game.Workspace:WaitForChild("Zednov's Tycoon Kit"):WaitForChild("Tycoons")
local player = game.Players:GetPlayerFromCharacter(hit.Parent)
game:GetService("BadgeService"):AwardBadge(player.UserId, 2125663262)
for _,child in pairs(Tycoons:GetChildren()) do
print("before found")
if player.Team == game.Teams[child.Name] then
print("child found")
--player.TeamColor = child.TeamColor.Value
--child.Owner.Value = player
player.RespawnLocation = child.Essentials.Spawn
player:LoadCharacter()
print("before break")
break
end
end
wait(0.1)
end
end)
This sort of issue usually occurs due to execution times, for example, you have a script that rotates the camera around an area, like a cutscene, however that cutscene is technically still running when you’re trying to reset the camera.
Also, always try to use the correct Class Type (CameraType is an Enum , not a string).
Yes the camera is rotating. Do you think that’s the issue?
local Cam = game.Workspace.Camera
local introCam = game.Workspace.Cam
repeat wait() until Cam.CameraSubject ~= nil
Cam.CameraType = Enum.CameraType.Scriptable
Cam.CFrame = introCam.CFrame
while Cam.CameraType == Enum.CameraType.Scriptable do
local x, y, z = Cam.CFrame:ToOrientation()
local Rot = y + math.rad(wait()*4)
if math.deg(Rot) >= 360 then Rot = 0 end
Cam.CFrame = CFrame.fromOrientation(x, Rot, z) + Cam.CFrame.Position
end
Yes, ensure that your rotation Script is stopped before resetting the camera.
As for what I meant by class type, others have suggested this.
cam.CameraType = “Custom”
However, CameraType is not a String (text), but an Enum.
cam.CameraType = Enum.CameraType.Custom
It is good coding practice to always use the correct type, and will be more performance as the system doesn’t have to try to convert the string to Enum for you.
You can also clearly see the different types of values with intelisense.