The script below I have had help to build to make GUI's show for players online as you can see from this link here: https://scriptinghelpers.org/questions/25624/why-does-this-gui-script-not-work-online
However I have now encountered a problem where textboxes will not carry out their functions when clicked on when the game is played online...
function touch(hit)
if hit.Parent:IsA('Model') then
local player = game.Players:FindFirstChild(hit.Parent.Name)
if player then
local screengui = Instance.new("ScreenGui")
screengui.Parent = player.PlayerGui
local textbutton = Instance.new("TextButton")
textbutton.Parent = screengui
textbutton.Position = UDim2.new(0.07, 14, 0.73, 15)
textbutton.Size = UDim2.new(0, 370, 0, 50)
textbutton.BackgroundColor3 = BrickColor.White().Color
textbutton.Text = "Click Me!"
textbutton.BorderSizePixel = 0
textbutton.FontSize = "Size14"
-- Bind function to button click
textbutton.MouseButton1Down:connect(function()
textbutton.Text = "I've been clicked!"
end)
elseif hit.Parent.Parent:IsA('Model') then
local player = game.Players:FindFirstChild(hit.Parent.Parent.Name)
if player then
local screengui = Instance.new("ScreenGui")
screengui.Parent = player.PlayerGui
local textbutton = Instance.new("TextButton")
textbutton.Parent = screengui
textbutton.Position = UDim2.new(0.07, 14, 0.73, 15)
textbutton.Size = UDim2.new(0, 370, 0, 50)
textbutton.BackgroundColor3 = BrickColor.White().Color
textbutton.Text = "Click Me!"
textbutton.BorderSizePixel = 0
textbutton.FontSize = "Size14"
-- Bind function to button click
textbutton.MouseButton1Down:connect(function()
textbutton.Text = "I've been clicked!"
end)
end
end
end
script.Parent.Touched:connect(touch)
I do not know what the problem with this is, as there is nothing showing in the output, so I have no idea...
EDIT
I managed to solve this by following the advice given in the comments and put it into a localscript, which worked a charm!

2 comments
is it in a local script?
Oh no.. It's in regular script inside a brick that the player touches