#Interesting, my camera does not go back to the player when i finish animation
1 messages · Page 1 of 1 (latest)
local connection = RunService.RenderStepped:Connect(function()
end)
To disconnect
connection:Disconnect()
@idle sun
i edited it a little bit but... it still doesn't work
`local function StartTheAnimationBruh()
local camrig = cutscenefolder:WaitForChild("CameraRig")
local camAnimation = camrig:WaitForChild("Animation")
local rig = cutscenefolder:WaitForChild("R6")
local animation = rig:WaitForChild("Animation")
local camtrack = camrig:FindFirstChild("Humanoid"):FindFirstChild("Animator"):LoadAnimation(camAnimation)
local r6track = rig:FindFirstChild("Humanoid"):LoadAnimation(animation)
task.wait(2)
camera.CameraType = Enum.CameraType.Scriptable
r6track:Play()
task.wait(0.1)
camtrack:Play()
sound:Play()
connection = runservice.RenderStepped:Connect(function()
print("Camera Running")
camera.CFrame = camrig.Torso.CFrame
end)
end
cutscenelocal.OnClientEvent:Connect(function()
StartTheAnimationBruh()
task.wait(18.5)
connection:Disconnect()
camera.CameraType = Enum.CameraType.Custom
`
it worked onece now it doesn't
** You are now Level 9! **
hello
do you want a video? or a picture of the script... anything?
so everything works perfect once then it doesn't work at all?
it worked good at first but when i added a system of importing a rig from replicated storage now it doesn't work
no errors the disconnect doesn't do it's job for me to be able to change the camera type into custom
add this at the top of your script (outside of any function)
local connection = nil
then below the line where you disconnect add
connection = nil
wait I'm slow
but why doesn't it disconnect...
same question ill make a video to show you
disconnect if statement didn't even show (i added a script and i show it at the last part)
hmm
so the animation and everything is playing
I am so confused
why isn't it disconnecting?
dont know 😭
try connection:Disconnect() before starting the animation
just to see if that works
like right under .OnClientEvent
wait nvm u need to run that function for the connection to start
I have to be blind
This isn't something hard to fix I just can't think 😭
I've used RunService so many times
try
if connection then
connection:Disconnect()
else
print("connection is nil")
end
ok
there is also BindToRenderStep
https://create.roblox.com/docs/reference/engine/classes/RunService#BindToRenderStep
I am so confused
sorry for lag game is going at 2000 MB 😭
i need to hire an optimizer
also what this means
BindToRenderStep(name : string,priority : number,function : function):() Given a string name of a function and a priority, this method binds the function to RunService.PreRender
in other words in this script it actually did the thing that dissconnected was not nil but i don't know what dissconect doin
@young lake add
connection = nil
right after you run
connection:Disconnect()
In summary:
connection:Disconnect()
connection = nil
sorry i had to do something but if you want to hop in the studio to help i guess you can because I am as confused as you on this 😔 @idle sun
could you send the entire script?
`local replicatedstorage = game:GetService("ReplicatedStorage")
local cutscenefolder = game.Workspace.Cutscene
local player = game.Players.LocalPlayer
local bind = replicatedstorage.changeCameraType
local camera = workspace.CurrentCamera
local runservice = game:GetService("RunService")
local cutscenelocal = replicatedstorage.CutsceneRemotes.CutsceneLocal
local cutscenefinish = replicatedstorage.CutsceneRemotes.CutsceneFinish
local sound = script.YouDiDIT
local connection = nil
local function StartTheAnimationBruh()
local camrig = cutscenefolder:WaitForChild("CameraRig")
local camAnimation = camrig:WaitForChild("Animation")
local rig = cutscenefolder:WaitForChild("R6")
local animation = rig:WaitForChild("Animation")
local camtrack = camrig:FindFirstChild("Humanoid"):FindFirstChild("Animator"):LoadAnimation(camAnimation)
local r6track = rig:FindFirstChild("Humanoid"):LoadAnimation(animation)
task.wait(2)
camera.CameraType = Enum.CameraType.Scriptable
r6track:Play()
task.wait(0.1)
camtrack:Play()
sound:Play()
connection = runservice.RenderStepped:Connect(function()
print("Camera Running")
camera.CFrame = camrig.Torso.CFrame
end)
end
cutscenelocal.OnClientEvent:Connect(function()
StartTheAnimationBruh()
task.wait(18.5)
if connection then
print("cam stop")
connection:Disconnect()
connection = nil
camera.CameraType = Enum.CameraType.Custom
else
print("Connection Is nil")
end
end)
`
try adding
if connection then return end
here
if conenction then return end
connection = runservice.RenderStepped:Connect(function()
print("Camera Running")
camera.CFrame = camrig.Torso.CFrame
end)
local replicatedstorage = game:GetService("ReplicatedStorage")
local runservice = game:GetService("RunService")
local cutscenefolder = game.Workspace.Cutscene
local player = game.Players.LocalPlayer
local bind = replicatedstorage.changeCameraType
local camera = workspace.CurrentCamera
local cutscenelocal = replicatedstorage.CutsceneRemotes.CutsceneLocal
local cutscenefinish = replicatedstorage.CutsceneRemotes.CutsceneFinish
local sound = script.YouDiDIT
local connection = nil
local function StartTheAnimationBruh()
local camrig = cutscenefolder:WaitForChild("CameraRig")
local camAnimation = camrig:WaitForChild("Animation")
local rig = cutscenefolder:WaitForChild("R6")
local animation = rig:WaitForChild("Animation")
local camtrack = camrig:FindFirstChild("Humanoid"):FindFirstChild("Animator"):LoadAnimation(camAnimation)
local r6track = rig:FindFirstChild("Humanoid"):LoadAnimation(animation)
task.wait(2)
camera.CameraType = Enum.CameraType.Scriptable
r6track:Play()
task.wait(0.1)
camtrack:Play()
sound:Play()
if conenction then return end
connection = runservice.RenderStepped:Connect(function()
print("Camera Running")
camera.CFrame = camrig.Torso.CFrame
end)
end
cutscenelocal.OnClientEvent:Connect(function()
StartTheAnimationBruh()
task.wait(18.5)
if connection then
connection:Disconnect()
connection = nil
camera.CameraType = Enum.CameraType.Custom
end
end)