How Do I Make A Gui Show To A Local Player?

Ok, so I have a local script. I tried

  1. game.Workspace.Part.Touched:Connect(function()
  2. if game.Players.LocalPlayer then
  3. game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = true
    But somehow all players see it.
workspace.Part.Touched:Connect(function(hit)
 local player = game.Players:GetPlayerFromCharacter(hit.Parent)
end)

I tried that and can still see it.

can you send your new code combined with my code?

Yes.
game.Workspace.Part.Touched:Connect(function(hit)
local Players = game.Players:GetPlayerFromCharacter(hit.Parent)
if Players then
game.Players.LocalPlayer.PlayerGui.ScreenGui.Enabled = true
end
end)

Heres a modified one.

game.Workspace.Part.Touched:Connect(function(hit)
local Players = game.Players:GetPlayerFromCharacter(hit.Parent)
if Players then
Players.PlayerGui.ScreenGui.Enabled = true
end
end)
3 Likes

game.Workspace.Part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
script.Parent.Enabled = true
end
end)

Put local script in screen gui

I copied and pasted that, all players can still see that. Im starting to wonder if studio is having issues.

This worked! Thanks so much! Been going through troubles.

1 Like