Having trouble making a part show a Gui when touched

so, I started to learn scripting really recently and I am trying to make a script that, when you touch a part a ScreenGui appears and I have no idea what I’m doing, I’m just mixing parts of scripting that I remember.

help!

1 Like

ScreenGui has not been defined previously. Do script.Parent.ScreenGui instead, as only having ScreenGui is not identifiable by the script.

1 Like

If your looking for something that makes a gui pop up when a part is touched, you’d have to use something like this:

        script.Parent.Touched:connect(function(hit)
     if hit.Parent:FindFirstChild("Humanoid") then
      game.Players.LocalPlayer.PlayerGui.ScreenGui.Frame.Visible = true
     end
    end)

if you ever change you gui name change all the ScreenGui to your new name

how does it know which part I want it to do this for?

You put this script inside of the part that you want this to fire for.

ok

30charrrrrrrsssssssssssssssssssssssssssss

Maybe something like this:

script.Parent.Touched:Connect(function(hit)
    if hit.Parent:FindFirstChild("Humanoid") then
        local plr = game.Players:GetPlayerFromCharacter(hit.Parent)
        script.Parent.ScreenGui:Clone().Parent = plr:WaitForChild("PlayerGui")
    end
end)

Make sure the gui is enabled.

1 Like

it didn’t do anything…

ihate30characters…

nothing happened

30charrrrrssssssssssssssss

Don’t put it inside a local script, put it in a regular one,m. And make sure the script is inside a part. And instead of using 30 character try to explain maybe what you had done wrong, or check your output.

1 Like

That’s weird. I hope I don’t have any typos.

And yeah,

and

1 Like