I'm trying to make a RemoteEvent
fire when a player presses 'e' when in a certain distance of the brick. I'm uncertain on how I :GetMouse()
and this is a LocalScript for FilteringEnabled
. Does anyone know how to fix this?
for _,v in pairs(game.Players:GetPlayers()) do mouse = v:GetMouse() end debounce = false Object = script.Parent mouse.KeyDown:connect(function(key) for i,v in pairs(game.Players:GetPlayers()) do distance = 5 if (v.Torso.Position - Object.Position).magnitude <= distance then if (key:lower()) == "e" and not debounce then debounce = true game.ReplicatedStorage.Found_Phone:FireServer() script.Parent:Destroy() end end end end)
Try doing local player = game.Players.LocalPlayer
and under that local mouse = player:GetMouse()
and do local workplayer = player.Name
and then do local actualplayer = Workspace:FindFirstChild(workplayer)
Then do
mouse.KeyDown:connect(function(key) disatance = 5 if (actualplayer.Torso.Position - Object.Position).magnitude <= distance then if key:byte() == 101 then -- your code here end end end)
You can find the KeyCodes here.
If that doesn't work, please let me know.
If it still doesn't work, please let me know!