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

How do I make my local script where it only effects 1 player?

Asked by 3 years ago

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:

01Poison3.Touched:Connect(function(hit,player)
02    local possibleCharacter = Humrp.Parent
03    local humanoid = hit.Parent:FindFirstChild("Humanoid")
04 
05    if hit.Parent == possibleCharacter and humanoid then
06        if not debounce1 then
07            debounce1 = true
08 
09            Stop:FireAllClients()
10            humanoid.Health = humanoid.Health+30
11            wait(60)
12            debounce1 = false
13        end
14    end
15end)

Local Script:

01local RemoteEvent = game.ReplicatedStorage.StopMove
02local Camera = workspace.CurrentCamera
03local char = game:GetService("Players").LocalPlayer.Character
04local player = game:GetService("Players").LocalPlayer
05local hum = char:WaitForChild("Humanoid")
06local TweenPart = hum
07local TS = game:GetService("TweenService")
08local debounce = false
09local humrp = char.HumanoidRootPart
10 
11local function stopfunction()
12 
13        if not debounce then
14 
15            debounce = true
View all 40 lines...

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

01local rp = game:GetService("ReplicatedStorage")
02local Spin = rp:WaitForChild("Spin")
03 
04local SpinModule = require(script.SpinModule)
05 
06Spin.OnServerEvent:Connect(function(Player)
07    local Character = Player.Character
08    local Humanoid = Character.Humanoid
09    local Humrp = Character.HumanoidRootPart
10 
11    local Folder = Instance.new("Folder")
12    Folder.Name = Player.Name.."Spin Move"
13    Folder.Parent = workspace -- parents the folder
14    game.Debris:AddItem(Folder,60) -- resets the move for the last 5 seconds
15 
View all 27 lines...

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!

0
Can you make a conclusion about what's the problem, because there is too much text Xeqro 20 — 3y
0
I don't really understand Xeqro 20 — 3y
0
i believe localscripts only affect one person. PaleNoobs 37 — 3y
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. AProgrammR 398 — 3y

Answer this question