I have:
script.Parent.Touched:connect(function(h) [script] end)
And i need this function could use h
player.PlayerGui.Gui.Button.MouseButton1Down:connect(function() [script] Part.Parent = h end)
It should look like this:
script.Parent.Touched:connect(function(h) if h.Name == "Test" then player.PlayerGui.Gui.Button.Visible = true end) player.PlayerGui.Gui.Button.MouseButton1Down:connect(function() local att = Instance.new("Attachment") att.Parent = h 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.
local holdH = 0 script.Parent.Touched:connect(function(h) holdH = h if h.Name == "Test" then player.PlayerGui.Gui.Button.Visible = true end) player.PlayerGui.Gui.Button.MouseButton1Down:connect(function() local att = Instance.new("Attachment") att.Parent = holdH 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.