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

Help with touched?

I have a part in workspace and this script is in the part. When I touch the part, I want the gui to pop up (Become visible)

partTouched = script.Parent.Touched:connect()

script.Parent.Touched:connect(function()

	if partTouched then
		game.StarterGui.ArrowGui.Frame.Visible = true
	
		
		
	end
end)

1 comment

0

This isn't ha very good question format can you please revise your question and explain it so that I could fix it :)

2 answers

script.Parent.Touched:connect(function(hit)
print("Step 1")
print(hit.Name)
   if hit.Parent:findFirstChild("Humanoid") ~= nil then
print("Step 2")
      player = game.Players:findFirstChild(hit.Parent.Name)
      player.PlayerGui.ArrowGui.Frame.Visible = true
print("Step 3")
    end
end)

2 comments

0

You know you could have just did on line 4 if hit.Parent:FindFirstChild('Humanoid') then

0

@Duckyo011 I tried that and he said it still didn't work so I don't know whats wrong with my code.

you have the partTouched all messed up, try using the values that come with the function like so:

partTouched = script.Parent.Touched -- this is a function, not a value

partTouched:connect(function(hit) -- to be used like this, where "hit" is the part that it was touched by

    if hit ~= nil then -- if you hit something

        game.StarterGui.ArrowGui.Frame.Visible = true -- do your stuff

    end

end)

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