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

help with checking when key is pressed on a specific part?

Asked by 4 years ago

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)

01if not debounce then
02 
03        debounce = true
04        if(hit.Parent:FindFirstChild("Humanoid")~=nil)then
05 
06 
07 
08 
09        local player = game.Players:GetPlayerFromCharacter(hit.Parent)
10        local sound = script.Parent.Sound:Clone()
11        sound.Parent = player.PlayerGui
12        sound:Play()
13        wait(5)
14        local player = game.Players.LocalPlayer
15        local mouse = player:GetMouse()
View all 27 lines...

end)

Answer this question