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

camera manipulation in server script?

Asked by
Plieax 66
6 years ago
01local this = script.Parent.Parent.detector
02local db = false
03 
04 
05this.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.cam1.CFrame
12            cam.CameraType = Enum.CameraType.Scriptable
13            cam.CameraSubject = this.Parent.Parent.camparts.cam1
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.

1 answer

Log in to vote
1
Answered by
yyyyyy09 246 Moderation Voter
6 years ago

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.

01local this = script.Parent.Parent.detector
02local db = false
03local remoteEvent = game:GetService("ReplicatedStorage"):FindFirstChild("RemoteEvent")
04--[[
05ReplicatedStorage is the gateway between the client and the server, it's where
06 
07you want to store your remote events
08--]]
09 
10this.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.cam1.CFrame,this.Parent.Parent.camparts.cam1)
15        --[[
View all 24 lines...

Local Script

You can put this in the StarterGui

01script.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 
10end)
Ad

Answer this question