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

CurrentCamera and PlayerGui is changing for all players?

Asked by 5 years ago

I've recently noticed while making games that need things to change for a single player; it affects every player ingame. I'm not sure why this is happening since CurrentCamera and PlayerGui used to change for a single player. I'm not sure if I'm just scripting it differently, or if Roblox happened to send out an update that changed this.

A script I have here is meant to change only for a single player, and it changes text in the player's GUI. Instead of changing for a single player, it changes for every player.

p = game.Players.LocalPlayer
camera = workspace.CurrentCamera

playergui = game:GetService('Players').LocalPlayer:WaitForChild('PlayerGui')

local debounce = false

local text = "Test"
gui = playergui.Texter

workspace.Stop.Touched:Connect(function()
    if debounce == false then
debounce = true
    for i = 1,#text do
        gui.TextLabel.Text = string.sub(text, 1, i)
        gui.TextLabel.TextLabel.Text = string.sub(text, 1, i)
        wait()
    end
    wait(2)
    debounce = false
        gui.TextLabel.Text = ""
        gui.TextLabel.TextLabel.Text = ""
    end
end)

The script itself works fine, but whenever a player touches the Stop (a part in the workspace) the text "test" will appear on everyone's screen.

Another situation like this with CurrentCamera occurs. I have used CurrentCamera to change blur, color correction, and more.

This script snippet, which will supposedly change the player's screen to have a more green feel and darker tint works (with bugs), but displays these effects to every player's screen like stated with the PlayerGui problem.

camera = workspace.CurrentCamera

            camera.correct.TintColor = Color3.fromRGB(125,143,123)
            for i = 0, -.15, -.05 do
                camera.correct.Brightness = i
                wait()
            end
        end

With that being said, I hope that somebody can help me with this problem as it is a regular occurrence and annoyance. I appreciate any help that I can receive, have a good night/day. :)

0
wheres the script located GoldAngelInDisguise 297 — 5y
0
Is it possible to see more of the second script? Is it a script or a localscript? In which circumstances is that snippet ran? DevNetx 250 — 5y
0
It's in the StarterCharacterScripts. The second script is in a local script and is in the StarterCharacterScripts as well. The snippet is ran when a part is touched, it also changes a GUI's text which also isn't local. Like the answer you gave me, I believe the problem is with .Touched event.   CaptainAlien132 225 — 5y

1 answer

Log in to vote
1
Answered by
DevNetx 250 Moderation Voter
5 years ago

With your first script, the .Touched event will fire when any players touches the part. This means that whenever any player touched it, the event will fire on all clients.

You should check whether the part touching it is part of the local player's character, then continue with whatever it's doing.

Ad

Answer this question