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

[ ANSWERED] How to check if a player has pressed a button in a billboardgui?

Hey everyone,

A few days ago, I watched a tutorial on E circles, where if you pressed it, it would teleport you to another game. The problem is, the game is for mobile players, too, and they don't have a keyboard. So is there a way to see if someone clicked or tapped on the button? I already tried MouseButton1Click and Activated.

Here is my code:

local inputservice = game:GetService("UserInputService")
local teleportservice = game:GetService("TeleportService")
local enterbutton = workspace.Map.MainTeleport.Doorknob.Gui.EnterButton

inputservice.InputBegan:Connect(function(i,g)
	if i.UserInputType == Enum.UserInputType.Keyboard then
		if i.KeyCode == Enum.KeyCode.E then
			local Mag = (workspace.Map.MainTeleport.Doorknob.Position-game.Players.LocalPlayer.Character.HumanoidRootPart.Position).magnitude
			if Mag <= 22 then
				workspace.Map.MainTeleport.Doorknob.Gui.EnterButton.BackgroundColor3 = Color3.fromRGB(145,145,145)
				wait(.1)
				workspace.Map.MainTeleport.Doorknob.Gui.EnterButton.BackgroundColor3 = Color3.fromRGB(255,255,255)
				for i = 0.1,5,.1 do
					wait(.1)
					enterbutton.Text = i
				end
				enterbutton.Text = "E"
				teleportservice:Teleport(5190764174, game.Players.LocalPlayer.Character)
			end
		end
	end
end)

Thanks!

1 answer

This is solved!

Looks like you need to place the billboardgui in the playergui!

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