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?