01 | local this = script.Parent.Parent.detector |
02 | local db = false |
03 |
04 |
05 | this.Touched:connect( function (hit) |
06 |
07 | if hit.Parent:FindFirstChild( "Humanoid" ) ~ = nil then |
08 | local char = hit.Parent |
09 | local plr = game.Players:WaitForChild(char.Name) |
10 | local cam = game.Workspace.CurrentCamera |
11 | cam.CFrame = this.Parent.Parent.camparts.cam 1. CFrame |
12 | cam.CameraType = Enum.CameraType.Scriptable |
13 | cam.CameraSubject = this.Parent.Parent.camparts.cam 1 |
14 |
15 | -- Create a camera change, a close button to that and a way to detect if the shop is open, Be Patient :) it will take a while -- |
16 |
17 | end |
18 | end ) |
I need it to be a server script to detect a player touching it but also i need the player who touched its camera to change please help.
with Filtering Enabled on which I'm guessing you're using, as you haven't stated otherwise. You want to use a remote function in ReplicatedStorage
This is the Server script.
01 | local this = script.Parent.Parent.detector |
02 | local db = false |
03 | local remoteEvent = game:GetService( "ReplicatedStorage" ):FindFirstChild( "RemoteEvent" ) |
04 | --[[ |
05 | ReplicatedStorage is the gateway between the client and the server, it's where |
06 |
07 | you want to store your remote events |
08 | --]] |
09 |
10 | this.Touched:connect( function (hit) |
11 |
12 | if hit.Parent:FindFirstChild( "Humanoid" ) ~ = nil then |
13 | local player = game:GetService( "Players" ):GetPlayerFromCharacter(hit.Parent) |
14 | remoteEvent:FireClient(player,this.Parent.Parent.camparts.cam 1. CFrame,this.Parent.Parent.camparts.cam 1 ) |
15 | --[[ |
Local Script
You can put this in the StarterGui
01 | script.Parent.RemoteEvent.OnServerEvent:Connect( function (player, positioning, subject) |
02 |
03 | local char = hit.Parent |
04 | local plr = game:GetService( "Players" ).LocalPlayer |
05 | local cam = game.Workspace.CurrentCamera |
06 | cam.CFrame = positioning |
07 | cam.CameraType = Enum.CameraType.Scriptable |
08 | cam.CameraSubject = subject |
09 |
10 | end ) |