The script I have made creates a GUI dialog on the touch of a brick. However it only works when played in the roblox studio, and not online, I am not sure why.. Is there anything wrong with the script?
function touch()
local screenGui = Instance.new("ScreenGui")
screenGui.Parent = game.Players.LocalPlayer.PlayerGui
local textLabel = Instance.new("TextLabel")
textLabel.Parent = screenGui
textLabel.Position = UDim2.new(0.55, 0, 0.7, 0)
textLabel.Size = UDim2.new(0, 600, 0, 200)
textLabel.BackgroundColor3 = BrickColor.DarkGray().Color
textLabel.TextWrapped = true
textLabel.FontSize = "Size28"
textLabel.Font = "SourceSansBold"
textLabel.Transparency = 0.4
textLabel.TextColor3 = BrickColor.White().Color
local finalText = [[ Hello there, ]]..game.Players.LocalPlayer.Name..[[
How are you]]
for i = 0, #finalText do
textLabel.Text = string.sub(finalText, 0, i)
wait(.05)
end
end
script.Parent.Touched:connect(touch)
