I Just Need a little help

Hello, actually there aren’t really any errors, it works fine, but it’s not the result I want. I would like that if a player activates the LocalScript, they can be the only one to see the auras of other players without the others seeing their own auras. Here’s an example of what I mean: if there are 3 players, player 1, player 2, and player 3, when player 1 presses Q, they see the aura of player 2 and player 3. However, players 2 and 3 don’t see their own aura or the aura of the player who sees theirs. But if they click Q in their turn, then they will see the aura of the other 2 respective players.

Script that generates auras when players join.

game.Players.PlayerAdded:Connect(function(player)
	player.CharacterAdded:Connect(function(character)
		local upperTorso = character:WaitForChild("UpperTorso")
		if upperTorso then
			local auraModel = game.ReplicatedStorage.Auras:FindFirstChild("ClassicAura")
			if auraModel then
				local aura = auraModel:Clone()
				aura.Enabled = false
				aura.Parent = upperTorso
			else
				warn("Aura model not found.")
			end
		else
			warn("UpperTorso not found for player:", player.Name)
		end
	end)
end)

The LocalScript

local AuraEvent = game.ReplicatedStorage.AuraEvent
local UserInputService = game:GetService("UserInputService")

local auraVisionActivated = false

UserInputService.InputBegan:Connect(function(input)
	if input.KeyCode == Enum.KeyCode.Q then
		auraVisionActivated = not auraVisionActivated
		print("Sending AuraEvent to server, activateAuraVision:", auraVisionActivated)
		AuraEvent:FireServer(auraVisionActivated)
	end
end)
k

The Script

local AuraEvent = game.ReplicatedStorage.AuraEvent

game.Players.PlayerAdded:Connect(function(player)
	AuraEvent.OnServerEvent:Connect(function(senderPlayer, activateAuraVision)
		print("Received AuraEvent for player:", senderPlayer.Name, "activateAuraVision:", activateAuraVision)

		local senderCharacter = senderPlayer.Character
		if senderCharacter then
			local upperTorso = senderCharacter:FindFirstChild("UpperTorso")
			if upperTorso then
				local aura = upperTorso:FindFirstChild("ClassicAura")
				if aura then
					if activateAuraVision then
						print("Activating aura vision for player:", senderPlayer.Name)
						aura.Enabled = true
						print("Aura activated for player:", senderPlayer.Name)
					else
						print("Deactivating aura vision for player:", senderPlayer.Name)
						aura.Enabled = false 
						print("Aura deactivated for player:", senderPlayer.Name)
					end
				else
					print("ClassicAura not found for player:", senderPlayer.Name)
				end
			else
				print("UpperTorso not found for player:", senderPlayer.Name)
			end
		else
			print("Character not found for player:", senderPlayer.Name)
		end
	end)
end)

1 Like

You should activate the auras on the local script since you only seem to want the player who’s turn it is to see them. It seems like there is no need for the remote event.
I cleaned up the code a bit for you, hope this helps!

local UserInputService = game:GetService("UserInputService")
local AuraVisionActivated = false
UserInputService.InputBegan:Connect(function(Input,GameProcessed)
	if GameProcessed then return end
	if Input.KeyCode == Enum.KeyCode.Q then else return end
	AuraVisionActivated = not AuraVisionActivated
	print("Aura vision active ", AuraVisionActivated)
	for i,v in pairs(game.Players:GetPlayers()) do
		local OtherCharacter = v.Character
		if OtherCharacter and OtherCharacter:IsDescendantOf(workspace) then else continue end
		local OtherTorso = OtherCharacter:FindFirstChild("Torso")
		if OtherTorso then else continue end
		local OtherCharacterAura = OtherTorso:FindFirstChild("ClassicAura")
		if OtherCharacterAura then else continue end
		OtherCharacterAura.Enabled = AuraVisionActivated
	end
end)

1 Like

Perfect, you’re saving me! I was thinking I would mainly have to use a LocalScript. I thank you immensely.

1 Like

Of course! For future reference, just make sure that if you only want a certain player to see something it can all be handled on the client side in a local script (or a module script required by a local script). Also, if you only want a single player to see something but the only way to do so is to call it on the server, such as a message to the specific player or perhaps effects like when a player is punched or cut by a sword, you can utilize RemoteEvent:FireClient() or RemoteEvent:FireAllClients() when you want to run things solely on the client (such as the auras) to save resources on the server, which will help with lag.

1 Like

thank you for your help, is noted !!

1 Like

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