You have to use UserInputService and its ImputBegan and InputEnded events. Mouse.KeyDown is deprecated.
local UserInputService = game:GetService("UserInputService")
local frame = script.Parent.EmoteFrame
frame.Visible = false
local player = game.Players.LocalPlayer
UserInputService.InputBegan:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.E and not gameProcessedEvent then
frame.Position = UDim2.new(0.5,0,0.059,0)
frame.Visible = true
end
end)
UserInputService.InputEnded:Connect(function(input, gameProcessedEvent)
if input.KeyCode == Enum.KeyCode.E and not gameProcessedEvent then
frame.Visible = false
end
end)
The InputBegan event fires when a client makes an input (keyboard keys, mouseButton, etc.) Then there's an if statement checking if the key is "E" and the player isn't in chat. Finally, it makes the frame visible.
The InputEnded event fires when a client ends an input (keyboard keys, mouseButton, etc.) Then there's an if statement checking if the key is "E" and the player isn't in chat. Finally, it makes the frame invisible.