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

How would you make a key press filtering enabled?

Asked by 7 years ago
Edited 7 years ago
01local m = game.Players.LocalPlayer:GetMouse()
02db = true
03m.KeyDown:connect(function(k)
04    k = k:lower()
05    if k == "f" then
06        if script.parent.FlapSetting.Value <= 2 then
07        script.parent.FlapSetting.Value = script.parent.FlapSetting.Value + 1
08        end
09    end
10end)

This works flawlessly without FE enabled but has no function whatsoever when I enabled it. It is in a local script

0
I have tried using remote events I still has to functionality carsheep -8 — 7y

1 answer

Log in to vote
0
Answered by 7 years ago
Edited 7 years ago

Do something like when the player presses a key on a LocalScript, it fires a remote event that the server sided script picks up. The server will do all the changing values and stuff.

Here's an example.

Note: I used UserInputService as Roblox says the mouse keydown function is deprecated. Basically, they recommend using this one.

LocalScript

1game:GetService("UserInputService").InputBegan:connect(function(key)
2    if key.KeyCode == Enum.KeyCode.F then
3        script.Parent.RemoteEvent:FireServer() -- RemoteFunction can be anywhere, as long as the server script knows where it is.
4    end
5end)

Script

1script.Parent.RemoteEvent.OnServerEvent:connect(function(plr)
2    --The first argument in an OnServerEvent is the player who fired the RemoteEvent.
3 
4    --Code here, this will be in a server script so everyone see's the change.
5end)
Ad

Answer this question