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:

	Poison3.Touched:Connect(function(hit,player)
		local possibleCharacter = Humrp.Parent
		local humanoid = hit.Parent:FindFirstChild("Humanoid")
		
		if hit.Parent == possibleCharacter and humanoid then
			if not debounce1 then
				debounce1 = true
				
				Stop:FireAllClients()
				humanoid.Health = humanoid.Health+30
				wait(60)
				debounce1 = false
			end
		end
	end)

Local Script:

local RemoteEvent = game.ReplicatedStorage.StopMove
local Camera = workspace.CurrentCamera
local char = game:GetService("Players").LocalPlayer.Character
local player = game:GetService("Players").LocalPlayer
local hum = char:WaitForChild("Humanoid")
local TweenPart = hum
local TS = game:GetService("TweenService")
local debounce = false
local humrp = char.HumanoidRootPart

local function stopfunction()
		
		if not debounce then

			debounce = true
			Camera.CameraType = "Scriptable"
			local cam = game.ReplicatedStorage:WaitForChild("CamBlock"):Clone()
			cam.CFrame = humrp.CFrame*CFrame.new(0,-1,-16)*CFrame.Angles(0,math.rad(180),0)
			cam.Parent = workspace
			local TweenInfo = TweenInfo.new(1,Enum.EasingStyle.Circular,Enum.EasingDirection.Out,0)
			local Goal = {}
			Goal.CFrame = cam.CFrame
			local Tween = TS:Create(Camera,TweenInfo,Goal)
			Tween:Play()
			local controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
			controls:Disable()
			--game.Debris:AddItem(cam,3)
			--cam:Destroy()
			wait(3)
			Camera.CameraType = Enum.CameraType.Custom
			controls = require(game:GetService("Players").LocalPlayer.PlayerScripts.PlayerModule):GetControls()
			controls:Enable()
			cam:Destroy()

			wait(60)
			debounce = false
		end
end

RemoteEvent.OnClientEvent:Connect(stopfunction)

The Module script is inside the Server Script Service under a Server script. Here is the server script if needed!:

local rp = game:GetService("ReplicatedStorage") 
local Spin = rp:WaitForChild("Spin") 

local SpinModule = require(script.SpinModule) 

Spin.OnServerEvent:Connect(function(Player) 
	local Character = Player.Character 
	local Humanoid = Character.Humanoid
	local Humrp = Character.HumanoidRootPart 
	
	local Folder = Instance.new("Folder")
	Folder.Name = Player.Name.."Spin Move" 
	Folder.Parent = workspace -- parents the folder
	game.Debris:AddItem(Folder,60) -- resets the move for the last 5 seconds
	
	spawn(function() 
		SpinModule.rotate(Folder,Humrp)
	end)
	
	spawn(function()
		SpinModule.Rocks(Folder,Humrp)
	end)
	
	delay(60,function()
		Spin:FireClient(Player) 
	end)
end)

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!

4 comments

0

Can you make a conclusion about what's the problem, because there is too much text

0

I don't really understand

0

i believe localscripts only affect one person.

0

Localscript affect one person. A localscript is a script which is locally run inside of a client and not server-sided or any other client.