function onTouch(hit)
if hit.Parent:FindFirstChild("Humanoid") ~= nil then
if game.Players:FindFirstChild(hit.Parent.Name) ~= nil then
local player = game.Players:FindFirstChild(hit.Parent.Name)
if player:FindFirstChild("PlayerGui"):FindFirstChild("ScreenGui") == nil then
sg = Instance.new("ScreenGui")
sg.Parent = player:FindFirstChild("PlayerGui")
end
if player.PlayerGui.ScreenGui:FindFirstChild("MessageBox") == nil then
local f = Instance.new("ImageLabel")
f.Name = "MessageBox"
f.Position = UDim2.new(0.15, 0, 0.65, 0)
f.Size = UDim2.new(0, 0, 0, 0)
f.Image = "rbxgameasset://Images/07132e13ced5b1d6acf15e5dc35cb65a"
f.Parent = player.PlayerGui:FindFirstChild("ScreenGui")
f.BackgroundTransparency = 1
wait(0.2)
f:TweenSize(UDim2.new(0.7,0, 0,170), "In" ,"Quint", 170)
local m = Instance.new("TextLabel")
m.Position = UDim2.new(0.5, 0, 0.8, 0)
m.FontSize = "Size14"
m.TextColor3 = Color3.new(1,1,1)
m.Parent = f
-- TEXT SECTION --
-- The following will be simple enough to edit.
-- You may copy lines along with a waiting time, and edit the text/ wait time.
------------------------------------------
m.Text = "Welcome."
m.TextColor3 = Color3.new(0,1,0)
wait(3)
m.Text = "This is my game!"
m.TextColor3 = Color3.new(0,1,0)
wait(3.5)
m.Text = "Thank you."
m.TextColor3 = Color3.new(0,1,0)
wait(2)
------------------------------------------
f:Destroy()
end
end
end
end
script.Parent.Touched:connect(onTouch)
COMMUNITY QUESTION
Why won't my tweensize hint box script work?
1 answer
Hi! Your code was rather hard to read due to improper indenting. Please, read up on the wiki about indenting to better help your fellow scripters understand the problems.
Errors
- On line 8, there is a If Statement that is a bit confusing. Instead of using two
FindFirstChilds, use only one, as you're checking for two different objects, which could both either return true or false. This is an all or nothing if statement. My correction would be,
if player:FindFirstChild("PlayerGui") == nil then
if player.PlayerGui:FindFirstChild('ScreenGui') == nil
sg = Instance.new("ScreenGui")
sg.Parent = player:FindFirstChild("PlayerGui")
end
end
- On line 23, the third argument in
TweenSize, will force theTweenSizeto occur over the span of 120 seconds. If you would like to make it happen faster, I suggest reducing it, or removing the number altogether, as the default time is 1 second.
Tips
- When using
FindFirstChildin an if statement, you no longer need to use that, you can simply refer to it. I.e.
if player.PlayerGui:FindFirstChild('Batman') then
player.PlayerGui.Batman:Destroy()
end
--As opposed to
if player.PlayerGui:FindFirstChild('Batman') then
player.PlayerGui:FindFirstChild('Batman'):Destroy()
end
- When checking the validity of an instance, you do not need to use
~= nilas simply typingplayer.Character:FindFirstChild('Humanoid')will check the validity.
If my answer helped, please accept my answer.
Happy scripting!
This discussion is preserved as it was. New answers, comments, and votes are closed.

2 comments
I'm to make a hint box pop up and grow in the center of the screen.
Whenever posting a question you need to supply more data and properly indent your code. Please supply us with any errors that you receive via the Output.