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)
✓ ANSWER ACCEPTED
I'm trying to make a gui visible when my pickaxe hits a rock and this script doesn't work?
1 answer
✓ Accepted answer
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.
This discussion is preserved as it was. New answers, comments, and votes are closed.
