I am trying to make a part appear only while a player is touching it, and then when they no longer are touching it, it will return it to 1 transparency locally.
So far, I’ve had the beginning part of the script only work when it’s not a local script. I’m not sure if I’m missing something?
local myPart = script.Parent
local player = game.Players.LocalPlayer
-- Set initial transparency
myPart.Transparency = 1
-- Function to handle when the part is touched
local function onTouch()
-- Change part transparency to 0 when touched
myPart.Transparency = 0
end
-- Function to handle when the part is no longer touched
local function onUnTouch()
-- Change part transparency to 1 when not touched
myPart.Transparency = 1
end
-- Connect the onTouch function to the Touched event of the part
myPart.Touched:Connect(onTouch)
-- Connect the onUnTouch function to the TouchEnded event of the part
myPart.TouchEnded:Connect(onUnTouch)