I have:
1 | script.Parent.Touched:connect( function (h) |
2 | [ script ] |
3 | end ) |
And i need this function could use h
1 | player.PlayerGui.Gui.Button.MouseButton 1 Down:connect( function () |
2 | [ script ] |
3 | Part.Parent = h |
4 | end ) |
It should look like this:
1 | script.Parent.Touched:connect( function (h) |
2 | if h.Name = = "Test" then |
3 | player.PlayerGui.Gui.Button.Visible = true |
4 | end ) |
5 |
6 | player.PlayerGui.Gui.Button.MouseButton 1 Down:connect( function () |
7 | local att = Instance.new( "Attachment" ) |
8 | att.Parent = h |
9 | end ) |
But "MouseButton1Down:connect" function don't know what is h
Something like this would work. "H" is local to the Touched function you wrote. To make it usable by other functions, it must be defined outside of the Touched function.
01 | local holdH = 0 |
02 |
03 | script.Parent.Touched:connect( function (h) |
04 | holdH = h |
05 | if h.Name = = "Test" then |
06 | player.PlayerGui.Gui.Button.Visible = true |
07 | end ) |
08 |
09 | player.PlayerGui.Gui.Button.MouseButton 1 Down:connect( function () |
10 | local att = Instance.new( "Attachment" ) |
11 | att.Parent = holdH |
12 | end ) |
Hello,
You did not define what is "player" and what is "h".
Please define them first, if something goes wrong, or a problem occurs, feel free to comment.
Sincerely,
Arti_BLOX.