I tried making a script that opened a gui once touched but it doesn't work? What did I do wrong?
function ontouched(part) script.Parent.Parent.Parent.StarterGui.ScreenGui.ImageLabel.Visible = true script.Parent.Parent.Touched:connect(onTouch) end
The problem is because you typed the wrong function. Here I fix it for you:
-- in local script function onTouch() script.Parent.Parent.Parent.StarterGui.ScreenGui.ImageLabel.Visible = true print('Touched!') script.Parent.Parent.Touched:connect(onTouch)
But, I recommend you write like this:
-- in local script script.Parent.Parent.Touched:connect(function() script.Parent.Parent.Parent.StarterGui.ScreenGui.ImageLabel.Visible = true print('Touched!') end)
Because the second one is easier to type.
You have a couple of problems:
You are using StarterGui. You need to use PlayerGui on the person that pressed. Consider the example below.
You are connecting the function inside it's self. Don't do that!
function ontouched(part) local plr =game.Players:GetPlayerFromCharacter(part.Parent) if plr then plr.PlayerGui.ScreenGui.ImageLabel.Visible = true end end script.Parent.Parent.Touched:Connect(ontouched)