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

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

Asked by 4 years ago
Edited 4 years ago

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

0
Is this a localscript and where is it located? lukeh990 23 — 4y
0
i edited it Toastitions 11 — 4y

3 answers

Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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.

0
doesnt work. Toastitions 11 — 4y
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. Toastitions 11 — 4y
0
@Toastitions could you show us a video and a picture of the studio explorer, please? IvanJupiter 36 — 4y
Ad
Log in to vote
0
Answered by
zadobyte 692 Moderation Voter
4 years ago

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).

0
i edited the messgae its in a localscript in starterpack Toastitions 11 — 4y
Log in to vote
0
Answered by 4 years ago
Edited 4 years ago

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)
0
Not what im looking for. read the question Toastitions 11 — 4y
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 lukeh990 23 — 4y
0
@Toastitions I just tested it with a server the camera only changes for the player that touches it lukeh990 23 — 4y
0
you need to test with 2 player Toastitions 11 — 4y
View all comments (8 more)
0
@Toastitions I did with that script lukeh990 23 — 4y
0
where did you put the script? Toastitions 11 — 4y
0
StarterPack lukeh990 23 — 4y
0
didnt work for me though Toastitions 11 — 4y
0
Hold on just a sec I'm gonna make sure I put the right one up lukeh990 23 — 4y
0
Do you get any errors? lukeh990 23 — 4y
0
no its just that the cutscene just starts running on all screens Toastitions 11 — 4y
0
Did you make sure to copy paste it? lukeh990 23 — 4y

Answer this question