#Interesting, my camera does not go back to the player when i finish animation

1 messages · Page 1 of 1 (latest)

young lake
#

It worked the first time then when i wanted to change a couple stuff i doesn't work now and runservice just keeps going so HOW DO I STOP THE RUNSERVICE?

idle sun
#
local connection = RunService.RenderStepped:Connect(function()

end)

To disconnect

connection:Disconnect()
young lake
#

@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

idle sun
young lake
still voidBOT
#

studio** You are now Level 9! **studio

idle sun
#

hello

young lake
#

do you want a video? or a picture of the script... anything?

idle sun
#

so everything works perfect once then it doesn't work at all?

young lake
#

it worked good at first but when i added a system of importing a rig from replicated storage now it doesn't work

idle sun
#

what part of the script doesn't work how you want it to?

#

any errors?

young lake
#

no errors the disconnect doesn't do it's job for me to be able to change the camera type into custom

idle sun
#

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...

young lake
#

same question ill make a video to show you

idle sun
#

hmm

#

so the animation and everything is playing

#

I am so confused

#

why isn't it disconnecting?

young lake
#

dont know 😭

idle sun
#

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

young lake
#

yea

#

@robust halo we might need help on this one

idle sun
#

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
young lake
#

ok

idle sun
young lake
idle sun
#

I am so confused

young lake
#

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

idle sun
#

@young lake add

connection = nil

right after you run

connection:Disconnect()

In summary:

connection:Disconnect()
connection = nil
young lake
#

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

idle sun
young lake
#

`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)

`

idle sun
#

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)
young lake
#

YESS NICE!!! it works! (now i gotta add one more thing closing blackframe 😅 )

#

i don't know how it works but it does