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

Why is this not working?

So for some reason when you press a button the camera DOES go into first person. So I made it when you die it goes back into third person mode, but it doesn't work?

local deploy = script.Parent
local pgui = gui.Parent
local player = pgui.Parent



deploy.MouseButton1Down:connect(function()
		player.CameraMode = Enum.CameraMode.LockFirstPerson
    end
end)


function Death()
	if game.Players.LocalPlayer:FindFirstChild("Humanoid").Health <= 0 then
		player.CameraMode = Enum.CameraMode.Classic
	end
end

So you see that the deploy button does work when you press the camera but when you have < or = to 0 health then it doesn't work?

2 comments

0

This is obviously not the whole script. If you could show us the whole script that would be awesome. Or at least where you define your variables and call your functions.

0

You don't have "Death" connected to any event... Also, the Humanoid isn't a part of the player. It's a part of the character

1 answer

The Player doesn't have a humanoid.

player = game.Players.LocalPlayer
character = player.CharacterAdded:wait()

character:WaitForChild("Humanoid").Died:connect(function()
	player.CameraMode = "Classic"
end)

9 comments

0

Still didn't work ;p

0

Still didn't work ;p

0

Are you in a local script?

0

My bad. I didn't even read what you were trying to do. :P

0

oh.

0

no it's not a local script btw

0

Put this in a local script. You can't use LocalPlayer unless you're in one.

0

Didn't work :p

0

I don't know camera syntax so you'd have to learn that on your own, but the Died function is the way to go if you want to do something upon the death of your character.

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