Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

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

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)

1 answer

✓ Accepted answer

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!

4 comments

0

Thank you very much! I appreciate it!

0

No problem!

0

Woah do I place it in a localscript, and in Starter Gui?

0

You would place the code in a LocalScript in the StarterGUI

This discussion is preserved as it was. New answers, comments, and votes are closed.