Better ways to do Keybinding

Hello DevForum,

im currently working on a roleplay game and i want to make some parts of my game with keybinds like to open close, lock and knock on the door.

Im currently using for that a local script inside the playergui that checks the distance between humanoidrootpart and the door. Also its a global script this is what i call it because it uses a tag system so i just have to add the certain part into the tag and boom it works.

However to get the door open i use a fireevent to server and i realized that exploiters could just fire the event themselves. How would i make the distance checked between player and the tag on the server ?

here is a demonstration https://gyazo.com/ce184effc185588b16bce5b6eaf83f11 thats how my doors work

Have the client fire over the door as an argument and have it check on the server.

you mean pass the distance as infomation and make the server check if its in distance ?.

Also what i realized when the player dies the output gets spammed away “humanoidrootpart not found” and then it stops when he respawned.

can i like disconnect the distance checker and then connect the function back when the player is respawned ?

No, I mean pass the door object as an argument of :FireServer() and have It check the distance on the server. Your other problem is easily fixed by checking if the HumanoidRootPart exists before doing anything. for example:

if HumanoidRootPart then
--code here
end

i dont use the door as object i use tags

but thanks for the help imma try that