Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How do i make this gui show to only the player that touched the part instead of everyone?

So my problem is that this GUI shows for everybody This is the script that shows the GUI

game.Workspace.ShopPart.Touched:Connect(function(hit)
	if hit then
		script.Parent.Shop.Frame.Visible = true
	end
end)

I tried everything I knew but it didn't work out. Does anyone know what can I do with this code to fix it?

2 answers

✓ Accepted answer
game.Workspace.ShopPart.Touched:Connect(function(hit)
	if hit:IsA("BasePart") then -- checking if hit isnt accessory or something like that
		if hit.Parent:FindFirstChild("Humanoid") then -- if we can find Humanoid inside hit.Parent if yes, then hit.Parent is player

 	local player = game.Players:GetPlayerFromCharacter(hit.Parent) -- hit can be Arm, Head, Torso so we want Parent of that which is player

				player.PlayerGui.Shop.Frame.Visible = true -- you need to put that gui inside StarterGui

		end
	end
end)

1 comment

0

Thank you so much! I really appreciate the explanation too!

 script.Parent.Shop.Frame.Visible=game.Players.LocalPlayer.Name==hit.Parent.Name

This discussion is preserved as it was. New answers, comments, and votes are closed.