Localscript making server changes

Hello!

I’ve coded some stuff with a localscript and it’s for some reason making changes server side. All the changes are based on a .Touched() event on multiple parts and all of the script is transfering to the server when i need it to only work for the client.

Does anyone know why this happens and how to fix it?

can I see the script? I’m no idea to help if doesn’t have it

redirectory1.Buttons.Button1.Main.Touched:Connect(function(h)
	if h.Parent:FindFirstChildOfClass("Humanoid") and h.Parent:FindFirstChildOfClass("Humanoid").Health > 0 then
		if db1 == true then return end
		db1 = true
		
		redirectory1.ImportantParts.Button1.Transparency = 1
		redirectory1.ImportantParts.Button1.CanCollide = false
		
		redirectory1.Buttons.Button1.Main.Button:Play()
		
		redirectory1.Buttons.Button1.Main.Beam.Enabled = false
		redirectory1.Buttons.Button1.Main.PointLight.Enabled = false
		redirectory1.Buttons.Button1.Main.Color = Color3.fromRGB(20, 20, 20)
		
		task.wait(75)
		
		db1 = false
		
		redirectory1.ImportantParts.Button1.Transparency = 0
		redirectory1.ImportantParts.Button1.CanCollide = true
		
		redirectory1.Buttons.Button1.Main.Beam.Enabled = true
		redirectory1.Buttons.Button1.Main.PointLight.Enabled = true
		redirectory1.Buttons.Button1.Main.Color = Color3.fromRGB(13, 105, 172)
	end
end)

That’s just a part of the script, but all of it changes those same settings. Mostly basic settings, transparency, cancollide, etc.

Sorry for taking so long, i went to sleep.

From what I can see, that should be impossible. How do you know it makes changes on the server side? Perhaps you’re viewing it from another client’s perspective (ex. 2plr test) instead of the actual server?

When i touched a part it made changes for other players aswell, maybe it isn’t actually making server changes but i do need it to only work for the one client that triggered the action.

Is it possible for you to take a screen recording showing this?

Yeah, just in a bit. Hang on, i’ll record it

https://gyazo.com/c9d9c298652237e1fd4a6e744bfbd333

The button is only supposed to open the door for one player aswell as the flood is only supposed to start rising after the player touches the ground, but it’s happening for all players.

Can I get some more context? It;s quite hard to understand what’s happening in the video, like what door is supposed to open for the local player only?

If possible, I’d also like to see the hierarchy of your explorer as well as the full code of what was previewed above.

The game is essentially Flood Escape only it’s supposed to be singleplayer type version, every player presses the button and it only makes changes for them. The flood is also coded so it starts when the player first touches the ground.

Though what’s happening is that those changes are happening for all players. The beggining of the code is essentially just stablishing variables.

local redirectory1 = game.Workspace.Minigames.FloodEscape.Map1

local db1 = false

image

The code is bigger than that but all of it just follows the same steps of

  1. Button was touched
  2. Run code (change transparency, collisions, etc)

It’s all in a localscript in StarterGui

Thanks but in the video you didn’t show how the button looked in the other player’s perspective. The only thing I saw happen for both players was the water rising, so I’m guessing its a script that controls the water.

Oh, the button turns black and you can see in the corner of the screen that the door disappears in the first player’s screen aswell.

It’s because the .Touched event fires on all the clients, you should check that the character touching the part is the LocalPlayer’s character.

1 Like

Oh, I missed that. Did you check whether the door was visible or not in the server though?

I actually forgot to do that, but i don’t think so.

I’ll take a look at that, thanks.

Oh :skull::skull::skull::skull::skull:

I did not notice that. That must be 100% the cause of the problem.

1 Like