ShopGui script opens gui on every players screen

When a player touches a part, I want this Shop UI to open and stop their walkspeed.

For some reason, it does this for every player when one person touches the part.

Player 1 (The one pressing the part):
image

Player 2:
image

I have tried looking around the dev forum but i haven’t really got anywhere.

hitbox.Touched:Connect(function(hit)
	if d == true then
		d = false
	
	if hit and hit.Parent:FindFirstChild("Humanoid") then
		
		local plr = hit.Parent
		
		script.Parent.Enabled = true
		script.Parent.storeOpen:Play()
		

		event:FireServer(plr) -- prevent walking
		
		end
	end
end)

script.Parent.Exit.Activated:Connect(function()
	
	

	
	script.Parent["Click SFX"]:Play()
	closeGui()							-- little animation, then closes the gui.
	event2:FireServer(16)				-- continue walking
end)


ob1.Touched:Connect(function(hit)		-- each of these make it so the shop is able to be reopened.
										
		d = true
	
end)

ob2.Touched:Connect(function(hit)
	d = true
	

end)

ob3.Touched:Connect(function(hit)
	d = true
	
end)

I should also mention that this is a local script.
The events just lead to a script that change the walkspeed of the player based on which event is fired, but i dont think that that is the problem.
I’m sure I’m just missing something and can’t realize but for some reason i am blanking here. Thank you!

1 Like

If you’ve made it a Script and not LocalScript, it’s going to run it for every player. Make sure that your code is running in a LocalScript.

1 Like

I forgot to mention that it was a localscript, which is why i’m so confused. Ill edit the post though. Thank you