The Button disable other peoples Particles instead of yours

Hello everyone! hope you have a nice day

So i made GUI button that Disables your specific particle (Thanks to people who helped me)

Now for some reason, when i click on the button it disable Other people particles

here is the script:
type or paste code here

local Players = game:GetService("Players")
local button = Players.LocalPlayer.PlayerGui.EffectCtrl.SettingEf:WaitForChild("DisInf")
local enabled = true
print("First Work")

local function onCharacterAdded(character)
	local Torso = character:WaitForChild("Torso")
	if Torso then
		local leftCollarAttachment = Torso:FindFirstChild("LeftCollarAttachment")
		if leftCollarAttachment then
			local aura = leftCollarAttachment:FindFirstChild("InfernusAura") or leftCollarAttachment:FindFirstChild("infernusAura")
			if aura then
				button.MouseButton1Click:Connect(function()
					enabled = not enabled -- toggle enabled value
					aura.Enabled = enabled
					print("Torso FOUND")
				end)
			else
				print("InfernusAura not found")
			end
		else
			print("LeftCollarAttachment not found")
		end
	else
		print("Torso not found")
	end
end

-- Access characters in Workspace
for _, player in ipairs(Players:GetPlayers()) do
	local character = player.Character or player.CharacterAdded:Wait()
	if character then
		print(player.Name .. " found in Workspace")
		onCharacterAdded(character)
	else
		print(player.Name .. " not found in Workspace")
	end
end

Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(onCharacterAdded)
	if player.Character then
		onCharacterAdded(player.Character)
	end
end)
1 Like

Where is this script located? Additionally, if you only want it to be disabled for the player locally, then why are you using a server script?

1 Like

the script located in StarterGUI

1 Like

probably because if it was a localscript it wouldn’t destroy for others
nevermind, he wants it to be locally i just realized

1 Like

Change the script to a LocalScript instead, since this will only enable and disable it only for the player who clicks on it.

1 Like

i already did before doing that

2 Likes

What happened? Did it work? Were there any errors?

1 Like

It disables others’ particles because you’re not adding a check to whether the player is the LocalPlayer or not. Paste the following code in a LocalScript inside the button (Players.LocalPlayer.PlayerGui.EffectCtrl.SettingEf:WaitForChild(“DisInf”))

local Players = game:GetService("Players")
local button = script.Parent
print("First Work")

local function onCharacterAdded(character)
	local Torso = character:WaitForChild("Torso")
	if Torso then
		local leftCollarAttachment = Torso:FindFirstChild("LeftCollarAttachment")
		if leftCollarAttachment then
			local aura = leftCollarAttachment:FindFirstChild("InfernusAura") or leftCollarAttachment:FindFirstChild("infernusAura")
			if aura then
				button.MouseButton1Click:Connect(function()
                    if aura.Enabled then
					    aura.Enabled = false
                    else
                        aura.Enabled = true
                    end
					print("Torso FOUND")
				end)
			else
				print("InfernusAura not found")
			end
		else
			print("LeftCollarAttachment not found")
		end
	else
		print("Torso not found")
	end
end

-- Access characters in Workspace
for _, player in ipairs(Players:GetPlayers()) do
	local character = player.Character or player.CharacterAdded:Wait()
	if character and character == Players.LocalPlayer.Character then
		print(player.Name .. " found in Workspace")
		onCharacterAdded(character)
	else
		print(player.Name .. " not found in Workspace")
	end
end
3 Likes

Hm, i will try it and tell you if it works or not

1 Like

There is no errors but the local Character isnt working
i will try Scr1pt_alt code and see if it works

2 Likes

I think it works so far! Thank you so much man
And thanks Herbz for helping me too!

3 Likes

Glad to help! Mark your post as solved.

3 Likes

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.