How do I make my local script where it only effects 1 player?
Hello fellow Roblox Lua programmers! I am in need of help to spawn a camera block that looks at my player character after touching a part! I am working on a domain move where it spawns a poison pit below my player, I would like whenever MY or ANY PLAYER THAT SPAWNS the poison pit and TOUCHES It will have a camera block spawn in front of them and look at their player character but it will not have any effects on other player's POV in the game or other players that are also touching the poison pit . The current issue is that, when the camera block spawns after the player who spawned the poison pit and touched it, not just their POV gets changed, everyone that is currently in the game or players that are standing in the poison pit's POV also gets changed.
I am currently using a module script, a local script and a server script. I tried to use a remote function and relate the module and local scripts together so I can create the effect in local script where only the player who spawned the poison pit and touches it will get the POV change effect.
Here is a short video of what I am trying to reference!
https://gyazo.com/de168abcb89c3b0f78893144e58bf8b3
As in the short recording above ^ You will see that when the poison pit is spawned, the player who spawned it will have their POV changed along with other players in the game whether just in game or standing in the poison pit. Another issue following this one is that the other players who got their POV changed due to this issue will not be able to have their POV changed when they personally spawned the domain. (Sorry if worded weirdly!)
Here are my scripts that need help..
Module script:
01 | Poison 3. Touched:Connect( function (hit,player) |
02 | local possibleCharacter = Humrp.Parent |
03 | local humanoid = hit.Parent:FindFirstChild( "Humanoid" ) |
05 | if hit.Parent = = possibleCharacter and humanoid then |
10 | humanoid.Health = humanoid.Health+ 30 |
Local Script:
01 | local RemoteEvent = game.ReplicatedStorage.StopMove |
02 | local Camera = workspace.CurrentCamera |
03 | local char = game:GetService( "Players" ).LocalPlayer.Character |
04 | local player = game:GetService( "Players" ).LocalPlayer |
05 | local hum = char:WaitForChild( "Humanoid" ) |
07 | local TS = game:GetService( "TweenService" ) |
09 | local humrp = char.HumanoidRootPart |
11 | local function stopfunction() |
16 | Camera.CameraType = "Scriptable" |
17 | local cam = game.ReplicatedStorage:WaitForChild( "CamBlock" ):Clone() |
18 | cam.CFrame = humrp.CFrame*CFrame.new( 0 ,- 1 ,- 16 )*CFrame.Angles( 0 ,math.rad( 180 ), 0 ) |
19 | cam.Parent = workspace |
20 | local TweenInfo = TweenInfo.new( 1 ,Enum.EasingStyle.Circular,Enum.EasingDirection.Out, 0 ) |
22 | Goal.CFrame = cam.CFrame |
23 | local Tween = TS:Create(Camera,TweenInfo,Goal) |
25 | local controls = require(game:GetService( "Players" ).LocalPlayer.PlayerScripts.PlayerModule):GetControls() |
30 | Camera.CameraType = Enum.CameraType.Custom |
31 | controls = require(game:GetService( "Players" ).LocalPlayer.PlayerScripts.PlayerModule):GetControls() |
40 | RemoteEvent.OnClientEvent:Connect(stopfunction) |
The Module script is inside the Server Script Service under a Server script. Here is the server script if needed!:
01 | local rp = game:GetService( "ReplicatedStorage" ) |
02 | local Spin = rp:WaitForChild( "Spin" ) |
04 | local SpinModule = require(script.SpinModule) |
06 | Spin.OnServerEvent:Connect( function (Player) |
07 | local Character = Player.Character |
08 | local Humanoid = Character.Humanoid |
09 | local Humrp = Character.HumanoidRootPart |
11 | local Folder = Instance.new( "Folder" ) |
12 | Folder.Name = Player.Name.. "Spin Move" |
13 | Folder.Parent = workspace |
14 | game.Debris:AddItem(Folder, 60 ) |
17 | SpinModule.rotate(Folder,Humrp) |
21 | SpinModule.Rocks(Folder,Humrp) |
25 | Spin:FireClient(Player) |
The Local Script is in StarterCharacterScripts
The Server Script is in Server Script Service
The Module Script is a child of the Server Script
Thank you so much for reading through and reaching out a helping hand! I am sorry if my code is hard to read/messy :( I am a beginner with Roblox Programming!
Help is very appreciated!