So far I have created a PopUp GUI which sorta works, but I can't figure out a way to make it only appear for one player. It either appears for everyone, or it causes massive lag spikes!?

Any Ideas?

Local Script

local CanOpen = true
local Event = game.ReplicatedStorage.OpenEvent.OpenGUI1



game.Workspace.Shop.Touch.Touched:Connect(function(plr)
	
	local Player = game:GetService("Players"):GetPlayerFromCharacter(plr.Parent)
	
	local Main = Player.PlayerGui:WaitForChild("PopUps")
	
	if Main and CanOpen == true then
	
		
		local Shop = Main:FindFirstChild("ChoosePrompt")
		
		local Shop1 = Main:FindFirstChild("EggShop")
		
		local Shop2 = Main:FindFirstChild("EggWeaponShop")
		
		if script.Parent.Opened.Value == false then
				
				Shop:TweenPosition(UDim2.new(0.3, 0,0.35, 0),'Out', 'Bounce', 0.5)
				
				script.Parent.Opened.Value = true
	
				CanOpen = false
				
				wait(1)
				
				CanOpen = true
				
		else
			
				warn("GUI OPEN")
			
			
			end
			
		end
end)

game.Workspace.Shop.Touch.TouchEnded:Connect(function(plr)
	
	script.Parent.Opened = false
	
end)

4 comments

0

Define Player as game.Players.LocalPlayer. Also, touchended events aren't very reliable so it may be very glitchy

0

Would post an answer but it won't let me.....

0

You can also make a script detecting the magnitude of the player's HumanoidRootPart to the middle point of the shop. If the magnitude is less than a certain amount than it pops up.

0

I tried game.Players.LocalPlayer but it pops up for everyone?