Inconsistent Disappearing of Objects For Local Player With Local Script

I’m having an issue with a LocalScript making changes that affect all players. There are objects in my game that I want to make disappear for only the player interacting with it. The objects should be visible for all other players. I’m attempting to make this work by placing the disappearing line of code (Transparency = 1) within a LocalScript. I’m getting mixed outcomes, with most making the object invisible for all players. I’m sure why this is happening since the transparency coding is in a LocalScript. Any insights? Here is my basic setup and LocalScript:

  • Starting with a baseplate game
  • Create 2 Parts in the game
  • Add a ClickDetector to one of them
  • Add a LocalScript under StarterPlayer → StarterPlayerScripts

Within the LocalScript add the following script. It uses the ClickDetector to turn one block transparent and uses the Touched event to turn the other block transparent:

game.Workspace.Part1.Touched:Connect(function()
   game.Workspace.Part1.Transparency = 1
   wait(10)
   game.Workspace.Part1.Transparency = 0
end)

game.Workspace.Part2.ClickDetector.MouseClick:Connect(function()
   game.Workspace.Part2.Transparency = 1
   wait(10)
   game.Workspace.Part2.Transparency = 0
end)

Run the game using two+ players. When Player #1 clicks Part2 with the ClickDetector, the parented block disappears for only Player #1. Perfect! However, if either player touches Part1, which is scripted with the Touched event, the block disappears for both players.

My understanding was that a LocalScript would only make changes for the LocalPlayer. I further replicated this problem when a .Changed event was used to make a part disappear in the LocalScript and the block disappeared for all players.

Does anyone have an explanation?
Does something more need to be added so that .Touched and .Changed can be used to only make changes for the local player in a LocalScript?

My guess is that, since .Touched event fires not only if a player touches the part but it can also fire when another part touches it. so it is made to always be server side? (Correct me if I’m wrong) . Also another way to do this would be using remote events, listen for the event in a local script and fire it in a script inside of each part. Sorry if I didn’t help you.

The .Touched event fires whenever ‘any’ part touches the block. This means when either player touches the part, .Touched is fired on both clients. To fix this, capture the part parameter and add "if part:IsDescendantOf(game.Players.LocalPlayer.Character) then – Set transparency end

This will filter out any other touched events from other players or parts in the game.

1 Like