I made a block that contains a TextButton, but for some reason the textbutton only detects clicks on specific spots, like the right side of the text or the very edge of the button. I tried replacing the textbutton with a textlabel and inserted a clickdetector instead, but the textlabel blocks the clickdetector. I also tried turning on AlwaysOnTop, it worked but I just dont want the buttons to be visible when im inside a building. Can someone help?
Code:
local cService = game:GetService("CollectionService")
local gasPumps = cService:GetTagged("gasPump")
local buttonDictionary = require(game.ReplicatedStorage.ModuleScripts.ButtonDict)
-- Browses through every pump tagged with "gasPump"
for _, pump in pairs(gasPumps) do
-- Creates a folder for the pump.
local folder = Instance.new("Folder")
folder.Name = pump.Name
folder.Parent = script.Parent.Instances
-- Creates a folder inside the PumpFolder for the buttons.
local bFolder = Instance.new("Folder")
bFolder.Name = "ButtonGUIS"
bFolder.Parent = folder
-- Browses through every object inside this script and clones it.
for _, obj in ipairs(script:GetChildren()) do
if obj:IsA("SurfaceGui") then
local screenCopy = obj:Clone()
screenCopy.Parent = folder
-- Puts the cloned SurfaceGUI into the screen of the tagged pump.
screenCopy.Adornee = pump:WaitForChild("Screen",true)
-- Places the Screen to its corresponding face position.
if screenCopy.Name:find("A") then
screenCopy.Face = "Front"
elseif screenCopy.Name:find("B") then
screenCopy.Face = "Back"
end
-- Enables the Background and Screen.
if screenCopy.Name:find("Background") or screenCopy.Name:find("Screen") then
screenCopy.Enabled = true
end
-- The object is a folder
elseif obj:IsA("Folder") then
-- Clones the folder
local guifolderCopy = obj:Clone()
guifolderCopy.Parent = folder
for _, gui in pairs(guifolderCopy:GetChildren()) do
gui.Adornee = pump:WaitForChild("Screen",true)
end
end
end
-- Loops through the Buttons.
for _, obj in pairs(pump:WaitForChild("Screen"):GetChildren()) do
-- Makes sure that we are ACTUALLY looping through the buttons folder.
if obj:IsA("Folder") then
-- i know you know this you dont need any commentary
local Sfolder = Instance.new("Folder")
Sfolder.Name = string.lower(obj.Name).."Folder"
Sfolder.Parent = bFolder
for _, button in ipairs(obj:GetChildren()) do
local numberEq = buttonDictionary[button.Name]
local surfaceGUI = Instance.new("SurfaceGui")
surfaceGUI.Parent = Sfolder
surfaceGUI.Enabled = true
surfaceGUI.Name = button.Name
local textButton = Instance.new("TextButton")
textButton.Text = numberEq
textButton.Parent = surfaceGUI
textButton.BackgroundTransparency = 1
textButton.Size = UDim2.new(1,0,1,0)
textButton.TextScaled = true
textButton.TextColor3 = Color3.fromRGB(255, 255, 255)
textButton.FontFace = Font.new("rbxasset://fonts/families/Zekton.json")
textButton.Visible = true
surfaceGUI.Adornee = button
surfaceGUI.Face = "Front"
surfaceGUI.CanvasSize = Vector2.new(100,100)
textButton.Active = true
-- test thing something
textButton.Activated:Connect(function()
print("Testtjuygfyueakfeuif")
end)
end
end
end
end
Video: 0724.mp4 - Google Drive (roblox wont let me upload the video directly)