Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How can I make the killcam unattach after a couple of seconds? [closed]

Asked by 10 years ago

This is what I did.

local player = script.Parent.Parent repeat wait() until Workspace.CurrentCamera repeat wait() until player.Character local C = Workspace.CurrentCamera player.Character.Humanoid.Died:connect(function() local killer = player.Character.Humanoid:findFirstChild("creator") if killer then for _,v in pairs(script.Parent:children()) do if v.Name ~= "KillCam" then v:remove() end end local G = Instance.new("ScreenGui",player.PlayerGui) local F1 = Instance.new("Frame",G) local F2 = Instance.new("Frame",G) F1.BackgroundColor3 = Color3.new(0/255,0/255,0/255) F2.BackgroundColor3 = Color3.new(0/255,0/255,0/255) F1.Size = UDim2.new(1,0,0,0) F2.Size = UDim2.new(1,0,0,0) F2.Position = UDim2.new(0,0,.85,0) Spawn(function() for i=1, 15 do wait() F1.Size = F1.Size + UDim2.new(0,0,.01,0) F2.Size = F2.Size + UDim2.new(0,0,.01,0) F2.Position = UDim2.new(0,0,1-(i*.01),0) end end) C.CameraSubject = killer.Value.Character C.CameraType = "Attach"

end end)

Closed as Not Constructive by evaera

This question has been closed because it is not constructive to others or the asker. Most commonly, questions that are requests with no attempt from the asker to solve their problem will fall into this category.

Why was this question closed?

1 answer

Log in to vote
1
Answered by
samfun123 235 Moderation Voter
10 years ago

Assuming that this code gets loaded every time the player spawns the simplest way to do this would be to just add a bit a code to reset the camera.

local player = script.Parent.Parent 
repeat wait() until Workspace.CurrentCamera 
repeat wait() until player.Character 
local C = Workspace.CurrentCamera 

C.CameraSubject = player.Character.Humanoid -- Reset the CameraSubject to the humanoid
C.CameraType = "Custom" -- Reset the CameraType to Custom

player.Character.Humanoid.Died:connect(function() 
    local killer = player.Character.Humanoid:findFirstChild("creator") 
    if killer then 
        for _,v in pairs(script.Parent:children()) do 
            if v.Name ~= "KillCam" then 
                v:remove() 
            end 
        end 
        local G = Instance.new("ScreenGui",player.PlayerGui) 
        local F1 = Instance.new("Frame",G) 
        local F2 = Instance.new("Frame",G) 
        F1.BackgroundColor3 = Color3.new(0/255,0/255,0/255) 
        F2.BackgroundColor3 = Color3.new(0/255,0/255,0/255) 
        F1.Size = UDim2.new(1,0,0,0) F2.Size = UDim2.new(1,0,0,0) 
        F2.Position = UDim2.new(0,0,.85,0)
        Spawn(function() 
            for i=1, 15 do 
                wait() 
                F1.Size = F1.Size + UDim2.new(0,0,.01,0) 
                F2.Size = F2.Size + UDim2.new(0,0,.01,0) 
                F2.Position = UDim2.new(0,0,1-(i*.01),0) 
            end 
        end) 
        C.CameraSubject = killer.Value.Character 
        C.CameraType = "Attach"
    end 
end)

If you have any questions, concerns or just need some help with this PM me on ROBLOX!

0
Thank you very much! I appreciate it! AlanLogic 0 — 10y
0
No problem! samfun123 235 — 10y
0
Woah do I place it in a localscript, and in Starter Gui? AlanLogic 0 — 10y
0
You would place the code in a LocalScript in the StarterGUI samfun123 235 — 10y
Ad