Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

How to make a hint box (on object touch) script locally?

Asked by 7 years ago
Edited 7 years ago

https://forum.roblox.com/Forum/ShowPost.aspx?PostID=215378968


The point of this script is for a hint box to appear *tween into view) on screen when an object is touched.

Since the ROBLOX Update my hint box script have not been working, so I asked how to fix it and I got answer like this...

local part = game.Workspace["Part name here."]

part.Touched:connect(function(h)
--DO YOUR STUFF HERE.
end)

there u go.

Pretty straightforward directions, but when I try to follow them,

local part = game.Workspace["Hint Ring"]

part.Touched:connect(function(h)
local player = game.Players:FindFirstChild(h.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 = "rbxassetid://752446664"                          
        f.Parent = player.PlayerGui:FindFirstChild("ScreenGui")
        f.BackgroundTransparency = 1

        local g = Instance.new("ImageLabel")
        g.Name = "MessageBox"
        g.Position = UDim2.new(0.17, 0, 0.68, 0)
        g.Size = UDim2.new(0.085, 0, 0.17,  0)      
        g.Image = "rbxassetid://629080158"                          
        g.Parent = player.PlayerGui:FindFirstChild("ScreenGui")
        g.BackgroundTransparency = 1

        local d = Instance.new("ImageLabel")
        d.Name = "MessageBox"
        d.Position = UDim2.new(0.17, 0, 0.68, 0)
        d.Size = UDim2.new(0.085, 0, 0.17,  0)      
        d.Image = "rbxassetid://629096041"                          
        d.Parent = player.PlayerGui:FindFirstChild("ScreenGui")
        d.BackgroundTransparency = 1







wait(1)
f:TweenSize(UDim2.new(0.7,0, 0,170), "Out" ,"Quad" , 0.5)


while true do
    wait(0.05)
    d.ImageTransparency=  1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency=  1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency=  1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency=  1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency=  1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency=  1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency=  1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency=  1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency=  1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency=  1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency=  1
    wait(0.05)
    d.ImageTransparency = 0
    break
end

wait(5)
f:TweenSize(UDim2.new(0, 0,0, 0), "Out" ,"Quad" , 0.5)
------------------------------------------
wait(1)
        d:Destroy()
        g:Destroy()
        f:Destroy()

        end
        end
    end
end
end)


Part.Touched:connect(function(h)

The script doesn't even run... Help? Please?

0
What is "hit" farrizbb 465 — 7y
0
@farizbb changed "hit" to "h" JoeRaptor 72 — 7y
0
You are triggering me by using a bunch of waiit()'s. You can use a numeric for loop to accomplish the ImageTransparency toggling. Shawnyg 4330 — 7y
0
Any errors? Did you try debugging? Set up print()'s around the script and say when it doesn't work. Shawnyg 4330 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago

Try this code, you added too many end declarations at the end of your code. I also cleaned it up for you.

local part = game.Workspace["Hint Ring"]

part.Touched:connect(function(h)
    local player = game.Players:FindFirstChild(h.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 = "rbxassetid://752446664"                          
    f.Parent = player.PlayerGui:FindFirstChild("ScreenGui")
    f.BackgroundTransparency = 1

    local g = Instance.new("ImageLabel")
    g.Name = "MessageBox"
    g.Position = UDim2.new(0.17, 0, 0.68, 0)
    g.Size = UDim2.new(0.085, 0, 0.17,  0)      
    g.Image = "rbxassetid://629080158"                          
    g.Parent = player.PlayerGui:FindFirstChild("ScreenGui")
    g.BackgroundTransparency = 1

    local d = Instance.new("ImageLabel")
    d.Name = "MessageBox"
    d.Position = UDim2.new(0.17, 0, 0.68, 0)
    d.Size = UDim2.new(0.085, 0, 0.17,  0)      
    d.Image = "rbxassetid://629096041"                          
    d.Parent = player.PlayerGui:FindFirstChild("ScreenGui")
    d.BackgroundTransparency = 1

    wait(1)
    f:TweenSize(UDim2.new(0.7,0, 0,170), "Out" ,"Quad" , 0.5)

    wait(0.05)
    d.ImageTransparency = 1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency = 1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency = 1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency = 1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency = 1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency = 1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency = 1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency = 1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency = 1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency = 1
    wait(0.05)
    d.ImageTransparency = 0
    wait(0.05)
    d.ImageTransparency = 1
    wait(0.05)
    d.ImageTransparency = 0

    wait(5)
    f:TweenSize(UDim2.new(0, 0,0, 0), "Out" ,"Quad" , 0.5)

    wait(1)
    d:Destroy()
    g:Destroy()
    f:Destroy()
end)

Part.Touched:connect(function(h)
0
The script doesn't even trigger now for some reason? JoeRaptor 72 — 7y
Ad

Answer this question