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

Why is this not working?

Asked by 8 years ago

Please make your question title relevant to your question content. It should be a one-sentence summary in question form.

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?

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. User#11440 120 — 8y
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 lightpower26 399 — 8y

1 answer

Log in to vote
0
Answered by
RedCombee 585 Moderation Voter
8 years ago

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)
0
Still didn't work ;p RetroThieff 5 — 8y
0
Still didn't work ;p RetroThieff 5 — 8y
0
Are you in a local script? RedCombee 585 — 8y
0
My bad. I didn't even read what you were trying to do. :P RedCombee 585 — 8y
View all comments (5 more)
0
oh. RetroThieff 5 — 8y
0
no it's not a local script btw RetroThieff 5 — 8y
0
Put this in a local script. You can't use LocalPlayer unless you're in one. RedCombee 585 — 8y
0
Didn't work :p RetroThieff 5 — 8y
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. RedCombee 585 — 8y
Ad

Answer this question