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

Camera Position Changing For All Players?

So i have a script and when you touch a block, it will fire an event and there is a local script in StarterGui and the local script will change the camera position of all players to like a shop thingy and this happens for all players and i only want it to happen to the player that touches the part, is there a way i can do that? Please help me lmoa

Server Sciript which is in the part which fires the remote event:

script.Parent.Touched:Connect(function()
	local event = game.ReplicatedStorage.Events:FindFirstChild("OpenVestShop")
  	event:FireAllClients()
end)

Local Script in the StarterGui

game.ReplicatedStorage.Events.OpenVestShop.OnClientEvent:connect(function()
    local plr = game.Players.LocalPlayer
    local cam = workspace.CurrentCamera
    local char = plr.Character

    repeat wait()
        cam.CameraType = Enum.CameraType.Scriptable
    until cam.CameraType == Enum.CameraType.Scriptable
    cam.CFrame = workspace.LifeJacketShop.ShopCameras.ShopCam1.CFrame
end)

Please post an answer! Please anything will help me ;)

1 answer

✓ Accepted answer
--Your server script
--define variable "part" as the part which touches this thing
script.Parent.Touched:Connect(function(part)
    --Check if the part that touches this thing is in a model that is owned by a player.
    local plr = game.Players:GetPlayerFromCharacter(part.Parent)
    if plr then
        local event = game.ReplicatedStorage.Events:FindFirstChild("OpenVestShop")
        event:FireClient(plr)
    end
end)

Don't use :FireAllClients() as it's self-explanatory: it sends the request to every player that exist in the server. :FireClient(Player player) works best in this situation!

Also, isn't the title a little bit misleading...?

2 comments

0

Thanks :DDDDD

0

Nice, worked for me too.

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