Here's my script, this binds the TouchEnded and Touched event which should help you understand Touch events a lot better.
local Players = game:GetService("Players")
local BasePart = (script.Parent:IsA("BasePart") and script.Parent) or script:FindFirstAncestorOfClass("BasePart")
BasePart.Touched:Connect(function(Hit)
local Character = (Hit.Parent:IsA("Model") and Hit.Parent) or Hit:FindFirstAncestorOfClass("Model")
pcall(function()
local Player = Players:GetPlayerFromCharacter(Character)
local PlayerGui = Player:FindFirstChildOfClass("PlayerGui")
PlayerGui.Quest1.Frame.Visible = true
end)
end)
BasePart.TouchEnded:Connect(function(Hit)
local Character = (Hit.Parent:IsA("Model") and Hit.Parent) or Hit:FindFirstAncestorOfClass("Model")
pcall(function()
local Player = Players:GetPlayerFromCharacter(Character)
local PlayerGui = Player:FindFirstChildOfClass("PlayerGui")
PlayerGui.Quest1.Frame.Visible = false
end)
end)
1 comment
Though tweaking can be done, this is the correct answer ^^. I'll accept it for ya!