So I'm trying to create a part where once you get in a certain radius of it, it will be outlined using a SelectionBox. This works perfectly fine, except when one player goes in the specified radius of the part, the part gets outlined for every player instead of just that one player. I'm doing this using a local script inside the PlayerGui that changes the transparency of the SelectionBox when you get close enough, so shouldn't it only happen for the LocalPlayer if I'm using a local script? This is what I have inside my local script in the player gui:
Task1Part = workspace:WaitForChild("Task1Part") -- The part to get outlined Task1Trigger = Task1Part:WaitForChild("Task1Trigger") -- The invisible part that detects when a player gets near enough to the part SelectionBox = Task1Part:WaitForChild("SelectionBox") -- The selection box whose "Adornee" property is set to the Task1Part Task1Trigger.Touched:Connect(function(Toucher) if Toucher.Parent.Humanoid and Toucher.Name == "HumanoidRootPart" then SelectionBox.Transparency = 0 end end) Task1Trigger.TouchEnded:Connect(function(Toucher) if Toucher.Parent.Humanoid and Toucher.Name == "HumanoidRootPart" then SelectionBox.Transparency = 1 end end)
So basically what I want to know is, how do you change the properties of an instance in the workspace for only one player? I have filtering enabled on and experimental mode off, and I can't figure it out, so any help would be highly appreciated. Thank you for reading!
If the filtering enabled is actived normally you can't view the changement with the server so other player doesn't view this changement. If I can you propose a other script to a maximum of optimisation.
local PlayerService = game:GetService('Players') local Player = PlayerService.LocalPlayer -- To found the player local Range = 15 -- Distance local Task1Part = workspace:WaitForChild("Task1Part") --local Task1Trigger = Task1Part:WaitForChild("Task1Trigger") -- You can remove it, it's no longer useful now:) local SelectionBox = Task1Part:WaitForChild("SelectionBox") while wait() do if Player.Character and (Player.Character.HumanoidRootPart.Position - Task1Part.Position).magnitude < Range then SelectionBox.Transparency = 0 else SelectionBox.Transparency = 1 end end
Make sure the SelectionBox are origin in the Studio transparent and that code is on a LocalScript! To more question ask below