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

How do i make this so it only works with he client??? I am not the best scripter. :P

I want to make this code down here, only work for the localplayer's camera.

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

local Part3 = game.Workspace.Part3

game.Workspace.Part3.Touched:connect(function()
	Camera.CameraType = Enum.CameraType.Scriptable
    Camera.CFrame = workspace.CameraParts3.CFrame
    wait(2)
    Camera.CFrame = workspace.CameraPart2s3.CFrame
    wait(3)
    Camera.CFrame = workspace.CameraPart3s3.CFrame
    wait(2)
    Camera.CFrame = workspace.CameraPart4s3.CFrame
end)

**right now it changes the camera of everyone in the game to those parts. i wanna make it so it only becomes the camera of the CLIENT when the CLIENT touches the part. **

FYI THIS IS A LOCALSCRIPT IN STARTERPACK

2 comments

0

Is this a localscript and where is it located?

0

i edited it

3 answers

✓ Accepted answer

Try this:

local Player = game.Players.LocalPlayer
local Players = game:GetService("Players")
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

local Part3 = game.Workspace.Part3

game.Workspace.Part3.Touched:connect(function(plr)
local TouchPlayer = Players:GetPlayerFromCharacter(plr.Parent.Name)
if TouchPlayer == Player.Name then
    Camera.CameraType = Enum.CameraType.Scriptable
    Camera.CFrame = workspace.CameraParts3.CFrame
    wait(2)
    Camera.CFrame = workspace.CameraPart2s3.CFrame
    wait(3)
    Camera.CFrame = workspace.CameraPart3s3.CFrame
    wait(2)
    Camera.CFrame = workspace.CameraPart4s3.CFrame
end
end)

EDIT: Please show a video of it happening to more players and a picture of the explorer.

3 comments

0

doesnt work.

0

doesnt work. i need it so it plays for client when client touches it. right now, you got it so a client touches it and the cutscene plays for the whoel server.

0

@Toastitions could you show us a video and a picture of the studio explorer, please?

There's a good chance this is because the script is a server script, with guis, server scripts replicate everything to every client (correct me if I'm wrong).

1 comment

0

i edited the messgae its in a localscript in starterpack

When the script sees anything touches it runs for everyone. FIX:

local Player = game.Players.LocalPlayer
local Character = Player.Character or Player.CharacterAdded:Wait()
local Camera = workspace.CurrentCamera

local Part3 = game.Workspace.Part3

Part3.Touched:connect(function(Hit)
    if Hit.Parent == Character then
    Camera.CameraType = Enum.CameraType.Scriptable
    Camera.CFrame = workspace.CameraParts3.CFrame
    wait(2)
    Camera.CFrame = workspace.CameraPart2s3.CFrame
    wait(3)
    Camera.CFrame = workspace.CameraPart3s3.CFrame
    wait(2)
    Camera.CFrame = workspace.CameraPart4s3.CFrame
    end
end)

12 comments

0

Not what im looking for. read the question

0

@Toastitions The other script ran on all clients because any time any part touched it it would trigger all clients I added a if preventing it from running if its not there character

0

@Toastitions I just tested it with a server the camera only changes for the player that touches it

0

you need to test with 2 player

0

@Toastitions I did with that script

0

where did you put the script?

0

StarterPack

0

didnt work for me though

0

Hold on just a sec I'm gonna make sure I put the right one up

0

Do you get any errors?

0

no its just that the cutscene just starts running on all screens

0

Did you make sure to copy paste it?

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