Custom Camera applying to everyone when it shouldn't

  1. What do you want to achieve? Keep it simple and clear!

This is a Camera system that when you touch a part your camera switches to a different part of the room/set. (See video for a clearer example)

  1. What is the issue? Include screenshots / videos if possible!

This is yet another system that already works, but for some reason keeps applying to everyone when It’s supposed to be Local. When I test it with more than 1 player, for some reason the Camera view that’s supposed to apply to one player shows to everyone, and then everyone is fighting with the system to see where they are going.

  1. What solutions have you tried so far? Did you look for solutions on the Developer Hub?

I haven’t been able to find any solutions on the Developer Hub. This used to work fully on a Local Script in StarterPlayerScripts then changed it to a RemoteEvent that operated from the server, then fired in the same LocalScript. Still doesn’t work.

The following is the code for the script, and also how I’m running the event:

Server Script:

Remotes.FireCamera.OnServerEvent:Connect(function(Player)
    for i, v in pairs(Configuration.CameraParts:GetDescendants()) do
        local Cameras = Configuration.CameraParts.Cameras

        if v:IsA("Part") then
            v.Touched:Connect(function()
                if v.Name == "LivingRoomFront" then
                    Remotes.SetCurrentCamera:FireClient(Player, Cameras.LivingRoomFront.CFrame)                        
                elseif v.Name == "LivingRoomSide" then
                    Remotes.SetCurrentCamera:FireClient(Player, Cameras.LivingRoomSide.CFrame)                        
                elseif v.Name == "KitchenFront" then
                    Remotes.SetCurrentCamera:FireClient(Player, Cameras.KitchenFront.CFrame)                        
                elseif v.Name == "BedroomFront" then
                    Remotes.SetCurrentCamera:FireClient(Player, Cameras.BedroomFront.CFrame)                        
                elseif v.Name == "BackyardFront" then
                    Remotes.SetCurrentCamera:FireClient(Player, Cameras.BackyardFront.CFrame)                        
                elseif v.Name == "UpstairsBedroomFront" then
                    Remotes.SetCurrentCamera:FireClient(Player, Cameras.UpstairsBedroomFront.CFrame)                        
                elseif v.Name == "LivingRoomSide2" then                        
                    Remotes.SetCurrentCamera:FireClient(Player, Cameras.LivingRoomSide2.CFrame)                        
                end    
            end)
        end
    end
end)

Local Script:

Remotes.FireCamera:FireServer(Player)

Example of what the camera is supposed to do:

Any help with this will be appreciated.

5 Likes

Can you show the full local script make sure that Player = game.Players.LocalPlayer and not game.Players

1 Like

It’s this:

local Players = game:GetService("Players")

local Player = Players.LocalPlayer
1 Like

has the “Player” Variable ever been changed throughout the script?

Can you test the game/script with multiple players and see if Remotes.FireCamera:FireServer(Player) is fired more than once?

1 Like

No, the Player variable has not been changed at all

1 Like

It has not been fired more than once

2 Likes

Why not just do this on the client?

1 Like

What is the “Configuration” variable in the second line of your script a Parent of?

That’s what it originally was. It didn’t work

1 Like

Configuration is in the workspace

1 Like

No, I mean like what’s inside of it, sorry.

image

1 Like

Is the LocalScript a Script with RunContext set to Client? Or is the LocalScript just a normal LocalScript?


Could we also see the LocalScript that has where this FireClient is going to?

1 Like

It’s just a normal local script

1 Like

Try this for your touch function on the server script. Also make sure to define player service if you haven’t already.

v.Touched:Connect(function(BasePart)
	if not BasePart.Parent or not BasePart.Parent:FindFirstChildOfClass("Humanoid") then 
		return 
	end
	
	if Players:GetPlayerFromCharacter(BasePart.Parent) ~= Player then
		return 
	end
	
	--Put the rest of your touch function here
end)
2 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.