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

How is this happening?? D:

I'm trying to prevent this from happening, but I got NO CLUE of what's going on here... Take a look:

wait() --ignore. for studio.
--variables--
Raiders=game.Teams.Raiders
Dunno=game.Teams.Dunno
c=game.Workspace.CurrentCamera
angle=0
player = game.Players:GetPlayerFromCharacter(script.Parent.Parent.Character)
--==--
if player.TeamColor==BrickColor.new("Really black") then --Team "Choose a side"
	script.Parent.Parent.PlayerGui.SelectSide.Main.Visible=true
	script.Parent.Parent.Character.Torso.Anchored=true
c=game.Workspace.Camera
c.CameraType="Scriptable"
	target=game.Workspace.Cameramodel.Position
	while true and wait() do
	c.CoordinateFrame=CFrame.new(target)*CFrame.Angles(0,angle,0)
	angle=angle+math.rad(0.1)
	end end

if player.TeamColor==BrickColor.new("Bright red") then --Team "Raiders"
	wait()
	script.Parent.Parent.PlayerGui.SelectSide.Main.Visible=false
	script.Parent.Parent.Character.Torso.Anchored=false
	c.CameraType="Fixed"
	target=script.Parent.Parent.Character.Head.Position
	c.CoordinateFrame=CFrame.new(target)
	
elseif player.TeamColor == BrickColor.new("Pastel yellow") then --Team "Dunno"
	wait()
	script.Parent.Parent.PlayerGui.SelectSide.Main.Visible=false
	script.Parent.Parent.Character.Torso.Anchored=false
	c.CameraType="Fixed"
	target=script.Parent.Parent.Character.Head.Position
	c.CoordinateFrame=CFrame.new(target)
	end

What it does is it LOCKS the target camera at the place it started off as when you die. I have a GUI with a script that you choose sides from to die, and switch to one of this teams. HELP WOULD BE APPRECIATED!!

1 answer

✓ Accepted answer

At the end, add the lines:

local hum = game.Players.LocalPlayer.Character:FindFirstChild('Humanoid')
hum.Changed:connect(function()
if hum.Health == 0 or hum.Health < 0 then
c.CameraType = 'Custom'
c.CoordinateFrame = hum
end
end)

What this script does is it checks when the humanoid or person dies. If they do, their camera gets positioned back to the humanoid. If this does not work, create a local script inside the StarterGui and place this script inside.

2 comments

0

'Local' should be 'local', and 'If' should be 'if', also, 'C' should be 'c', as the script is now, there will be multiple errors, possibly saying 'Incorrect Syntax', and 'Attempt to call 'C' (a nil value)', ect..

0

I was typing on my device. Sorry. Lol

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