Manipulating SurfaceGui on an equipped tool

I am trying to create a clipboard that allows you to type in text and send it via a webhook. However, I ran into a problem when I was not able to manipulate the SurfaceGui on the tool. Despite the SurfaceGui being in the PlayerGui, neither TextButtons nor TextBoxes could be pressed / edited.

Here is the code below:

-- [ Objects ] --
local tool = script.Parent
local holdingAnim = script.HoldingAnim

local paper = tool.Paper
local surfaceGui = paper.ClipboardGui

-- [ Functions ] --
tool.Equipped:Connect(function()
	local character = tool.Parent
	humanoid = character:FindFirstChild("Humanoid")

	local plr = game.Players:GetPlayerFromCharacter(character)
	surfaceGui.Parent = plr.PlayerGui; surfaceGui.Enabled = true

	local anim = humanoid:LoadAnimation(holdingAnim)
	anim:Play()
end)

tool.Unequipped:Connect(function()
	surfaceGui.Parent = paper; surfaceGui.Enabled = false

	for _, a in pairs (humanoid:GetPlayingAnimationTracks()) do
		a:Stop()
	end
end)

I hope this is not a bug, because it would ruin my entire project. :frowning:

Yes, clicking on TextBoxes on a SurfaceGui, and them not working is a bug. A way that you could fix this is by making it so that when the player equips the tool, it will receive any key press.
Here’s some source code. You would still need to add the part where it detects if the player is holding the tool, but that could be done very easily by checking if the tool is in the character model.

local m = game.Players.LocalPlayer:GetMouse()
m.KeyDown:connect(function(k)
(add the directory to the surfacegui textlabel here).Text = (add the directory to the surfacegui textlabel here)…k
end)

For some reason the 2 periods turned into 3 at the part that changes the text, so just change it to 2 dots.

1 Like