I was looking through youtube to find a script to make a cutscene using moon animator I followed his instructions and it works fine, the only problem I have is it keeps looping after it’s finished, what i want to do is let it play ONCE everytime you join, or respawn.
Serverscriptservice script:
game.Players.PlayerAdded:Connect(function(Player)
Player.CharacterAdded:Connect(function()
local Remote :RemoteEvent = game.ReplicatedStorage.CutsceneRemote
while true do
task.wait(5)
local Remote : RemoteEvent = game.ReplicatedStorage.CutsceneRemote
local CutsceneFolder :Folder = game.ReplicatedStorage.spawncut
Remote:FireClient(Player, Player.Character.HumanoidRootPart, CutsceneFolder)
end
end)
end)
StarterCharacterScripts script:
local RunService = game:GetService("RunService")
local Players = game:GetService("Players")
local RS = game:GetService("ReplicatedStorage")
local LocalPlayer = Players.LocalPlayer
local Character = LocalPlayer.Character or LocalPlayer.CharacterAdded:Wait()
local PlayerGui = LocalPlayer.PlayerGui
local Camera = workspace.CurrentCamera
local Remote = RS:FindFirstChild("CutsceneRemote") --/Change this to your destination of the remote
function Cinematic(Target, Folder)
local CinematicsFolder = Folder
local CurrentCameraCFrame = workspace.CurrentCamera.CFrame
Camera.CameraType = Enum.CameraType.Scriptable
local FrameTime = 0
local Connection
Connection = RunService.RenderStepped:Connect(function(DT)
local NewDT = DT * 60
FrameTime += NewDT
local NeededFrame = CinematicsFolder.Frames:FindFirstChild(tonumber(math.ceil(FrameTime)))
local NeededFOV = CinematicsFolder.FOV:FindFirstChild(tonumber(math.ceil(FrameTime)))
if NeededFrame then
Character.Humanoid.AutoRotate = false
game.StarterGui:SetCore("ResetButtonCallback", false)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, false)
Camera.CFrame = Target.CFrame * NeededFrame.Value
print("on")
if NeededFOV then
Camera.FieldOfView = tonumber(NeededFOV.Value)
end
else
Connection:Disconnect()
Connection = nil
game.StarterGui:SetCore("ResetButtonCallback", true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
Character.Humanoid.AutoRotate = true
Camera.CameraType = Enum.CameraType.Custom
Camera.CFrame = CurrentCameraCFrame
Camera.FieldOfView = 70
print("off")
end
Character.Humanoid.Died:Connect(function()
Connection:Disconnect()
Connection = nil
game.StarterGui:SetCore("ResetButtonCallback", true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.All, true)
game.StarterGui:SetCoreGuiEnabled(Enum.CoreGuiType.Backpack, false)
Character.Humanoid.AutoRotate = true
Camera.CameraType = Enum.CameraType.Custom
Camera.CFrame = CurrentCameraCFrame
Camera.FieldOfView = 70
print("off")
end)
end)
end
Remote.OnClientEvent:Connect(function(HumRP, Folder)
Cinematic(HumRP, Folder)
end)