help with checking when key is pressed on a specific part?
using a couple of different tutorials i created a code that when someone is on a part and they press e something would happen for testing purposes i made a sound play and to print pressed e when the player presses e the problem is the sound works fine but it keeps printing e wherever and not when the player is on the specific part could i please have some help?
here is my code.
debounce = false
script.Parent.Touched:connect(function(hit)
04 | if (hit.Parent:FindFirstChild( "Humanoid" )~ = nil ) then |
09 | local player = game.Players:GetPlayerFromCharacter(hit.Parent) |
10 | local sound = script.Parent.Sound:Clone() |
11 | sound.Parent = player.PlayerGui |
14 | local player = game.Players.LocalPlayer |
15 | local mouse = player:GetMouse() |
17 | mouse.KeyDown:connect( function (key) |
end)