Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Help with touched?

Asked by
FiredDusk 1466 Moderation Voter
8 years ago

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)
0
This isn't ha very good question format can you please revise your question and explain it so that I could fix it :) User#5978 25 — 8y

2 answers

Log in to vote
2
Answered by 8 years ago
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)

0
You know you could have just did on line 4 if hit.Parent:FindFirstChild('Humanoid') then duckyo01 120 — 8y
0
@Duckyo011 I tried that and he said it still didn't work so I don't know whats wrong with my code. User#5978 25 — 8y
Ad
Log in to vote
0
Answered by 8 years ago

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)

Answer this question