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

I'm trying to make a gui visible when my pickaxe hits a rock and this script doesn't work?

Asked by
ekweji 4
7 years ago
Edited by OldPalHappy 7 years ago
script.Parent.Activated:connect(function()
    script.Parent.Handle.Touched:connect(function(hit)
        local y = hit.Parent:FindFirstChild("Humanoid")
        if y then
            if script.Parent.Handle.Touched.Name == "Rock" then
                game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Visible = true
            end
        end
    end)
end)

1 answer

Log in to vote
0
Answered by
Tesouro 407 Moderation Voter
7 years ago

The Touched event returns a parameter named by you hit, which is the part that the Handle touched. In this block, instead of using script.Parent.Handle.Touched, you should use the hit:

if hit.Name == "Rock" then
    game.Players.LocalPlayer.PlayerGui.ScreenGui.TextBox.Visible = true
end

As .Touched is the event itself.

Ad

Answer this question