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

Camera manipulation [closed]

Asked by 11 years ago

I want to camera manipulate when someone enters but only enters not respawns but i do not know how, im am not the best scripter i only really know the basics, so please help me out, thank you.

0
I do not know how. But you can search on youtube. OR the roblox wiki. And maybe ask a great scripter. I once asked peaspod and he answered me. Try him. Randomplayer121 -2 — 11y

Locked by User#19524

This question has been locked to preserve its current state and prevent spam and unwanted comments and answers.

Why was this question closed?

3 answers

Log in to vote
2
Answered by
jobro13 980 Moderation Voter
11 years ago

The PlayerAdded event can NOT be used for this. It will run on the server and you will find yourself doing more work on finding if someone has joined or respawned than doing it via LocalScripts.

Please note that you cannot use Scripts (running on the server) to manipulate your camera. The camera is only available on the client, thus, via a LocalScript.

It's really simple to check. You create a LocalScript in StarterPack / StarterGui and put in a code which checks if a certain value is present in the LocalPlayer. If it is not, then you know that this is the first join. You can then create this value so new checks will find the value: the script will then know that this is a respawn and not a join.

local Player = game.Players.LocalPlayer

function Joined()
-- camera manipulation here.
end

if not Player:FindFirstChild("HasJoined") then
    Instance.new("StringValue", Player).Name = "HasJoined"
    Joined()
end

The actual Camera manipulation will normally use CameraType Enum.CameraType.Scriptable to do it's job. The only property relevant is then CoordinateFrame, which represents the CFrame of the Camera. You can manipulate this CFrame to create smooth Camera operations.

After you are done, make sure that you undo your changes and change the CameraType back to Enum.CameraType.Custom. You will then see your character again.

Ad
Log in to vote
0
Answered by 11 years ago

The PlayerAdded event comes in handy for doing this. It will only happen once, and that is when the person first enters the game.

In order to use PlayerAdded, you would have to put it in a script in Workspace with the following code:

game.Players.PlayerAdded:connect(function(player)
    --camera manipulation
end)

Since you did not describe what you wanted the camera to do when the Player enters, I cannot write out the code for you. When testing PlayerAdded, you shouldn't test it in play solo mode because the player is created before the scripts load. If you need any more help in the future, don't hesitate to post another question.

Log in to vote
0
Answered by
brianush1 235 Moderation Voter
11 years ago

@jobro13 PlayerAdded can be used, Localscripts can be cloned. Here's an example:

game.Players.PlayerAdded:connect(function(Player)
    script.LocalScript:clone().Parent = Player:WaitForChild("PlayerGui")
end)