(Solved) Gui Activation On part Touch

hi there i am needing help with making it so if you touch a part a gui will appear any ideas ?? heres what i have atm

part = game.Workspace.Part
part.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
game.StarterGui.ScreenGui.Frame.TextLabel.Visible = true
game.StarterGui.ScreenGui.Frame.Visible = false

	game.Workspace.Part.Transparency = 1
end

end)

Well first you didn’t format your post properly. Second try this:

part = game.Workspace.Part
part.Touched:Connect(function(hit, Player)
if hit.Parent:FindFirstChild(“Humanoid”) then
local gui = Player.PlayerGui
game.gui.ScreenGui.Frame.TextLabel.Visible = true
game.gui.ScreenGui.Frame.Visible = false
game.Workspace.Part.Transparency = 1
end
end)

Excuse my bad code formatting, I don’t have my PC as it’s 1 in the morning. This should work in a regular script for your part. If it continues erroring show me the output log so I can better help you with your error.

1 Like

seems to still not be right

Change it to this:

local part = game.Workspace.Part
part.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild(“Humanoid”) then
        part.CanTouch = false —-- for stopping infinite spam
        local gui = game.Players.LocalPlayer.PlayerGui
        gui.ScreenGui.Frame.TextLabel.Visible = true
        gui.ScreenGui.Frame.Visible = false
        part.Transparency = 1
    end
end)
1 Like

i tried it but still has the same problem

Screenshot of output?

1 Like

here :slight_smile:

Oh, I thought this was a localscript inside gui . Change it to that

1 Like

oh ok ill do that tjanks

Your solution:

game.Players.PlayerAdded:Connect(function(plr)
game.Workspace.Part.Touched:Connect(function(hit)
hit = hit.Parent
hit.PlayerGui.guiname.Visible = true
 end
end)
1 Like

Wouldn’t work, hit cannot be a player instance.

1 Like

Oof. I’ll edit it.

1 Like