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

I need a way to make a local camera for each player. How would I go about doing that?

I do understand that there is a default camera, but I am making a cut-scene for games, and every time one player steps on the activation brick, everyone goes through the cut-scene.. Can I get help with this problem? Here is the script:

wait(3)
local TweenService = game:GetService("TweenService")
local Camera = game.Workspace.CurrentCamera

local function MoveCamera(StartPart, EndPart, Duration, EasingStyle, EasingDirection)
	Camera.CameraType = Enum.CameraType.Scriptable
	Camera.CFrame = StartPart.CFrame
	local Cutscene = TweenService:Create(Camera, TweenInfo.new(Duration, EasingStyle, EasingDirection), {CFrame = EndPart.CFrame})
	Cutscene:Play()
	wait(Duration)
end
local function Cutscene()
    MoveCamera(game.Workspace.Camera, game.Workspace.PartA, 1.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
	MoveCamera(game.Workspace.PartA, game.Workspace.PartA, 0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
	MoveCamera(game.Workspace.PartA, game.Workspace.PartB, 1.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
	MoveCamera(game.Workspace.PartB, game.Workspace.PartB, 0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
	MoveCamera(game.Workspace.PartB, game.Workspace.PartC, 1.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
	MoveCamera(game.Workspace.PartC, game.Workspace.PartC, 0.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
	MoveCamera(game.Workspace.PartC, game.Workspace.PartD, 1.5, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
	MoveCamera(game.Workspace.PartD, game.Workspace.PartD, 0.2, Enum.EasingStyle.Cubic, Enum.EasingDirection.InOut)
	wait(.5)
	Camera.CameraType = Enum.CameraType.Custom
	Camera.CameraSubject = game.Players.LocalPlayer.Character:WaitForChild("Humanoid")
	end
	local enabled = false
workspace.brick.Touched:Connect(function(plr)
	if enabled == true then return end enabled = true
	plr.Parent.Humanoid.WalkSpeed = plr.Parent.Humanoid.WalkSpeed == 0
	plr.Parent.Humanoid.JumpPower = plr.Parent.Humanoid.WalkSpeed == 0
Cutscene()
plr.Parent.Humanoid.WalkSpeed = 16
plr.Parent.Humanoid.JumpPower = 50
wait(2)
enabled = false
end)

Thank you to anyone who can help me with this!

2 comments

0

I assume this script is a LocalScript, yes? If so then the fix is simple, just replace "plr.Parent" in the "workspace.brick.Touched" connection to "game.Players.LocalPlayer.Character". This will make all players animate their own camera, even if they didn't touch the part. If it's not a LocalScript, get back to me.

0

the script does work, just not the way i want it to. I want it to display on one players screen.

1 answer

✓ Accepted answer

Here's the solution:

Add an if statement to the start of the touch fuction checking if who touched the part has the same name of the local player, if yes, run your code, else do something that you want or just dont. Also add a local variable called player and assign it to the local player.

The function would look like this:

local player = game:GetService("Players").LocalPlayer

workspace.brick.Touched:Connect(function(plr)
    if player.Name == plr.Parent.Name then
    	if enabled == true then return end enabled = true
    		plr.Parent.Humanoid.WalkSpeed = plr.Parent.Humanoid.WalkSpeed == 0
    		plr.Parent.Humanoid.JumpPower = plr.Parent.Humanoid.WalkSpeed == 0
		Cutscene()
		plr.Parent.Humanoid.WalkSpeed = 16
		plr.Parent.Humanoid.JumpPower = 50
		wait(2)
		enabled = false
		end
	end
end)

Sorry for the late response!

1 comment

0

it worked! thank you! i needed to remove one of the ends, though.

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