Hey, This is my second attempt on a script i am attempting. I am trying to make a script that allows the player to unanchor a part if a key is pressed and touching a certain block, I have used a normal script and a module script, however the functions don't seem to connect with eachother:
Module Script:
local onKeyPress = {}
function onKeyPress(inputObject, gameProcessedEvent)
end
return onKeyPress
Script:
local OnKeyPress = require(game.Workspace.ModuleScript)
function onTouch(hit)
if **onKeyPress**().KeyCode == Enum.KeyCode.F and hit.game.workspace.Name == "DoorKick" then
script.Parent.Parent.DoorKick.Anchored = false
script.Parent.Parent.DoorKick.CanCollide = false
end
end
script.Parent.Touched:connect(onTouch)
game:GetService("UserInputService").InputBegan:connect(**onKeyPress**)
I put bold underneath the error and it says: W001: Unknown Global 'OnKeyPress'

5 comments
.KeyCode() is not a value inside the onKeyPress function.
you can't use userinputservice on the server
You also have different capitalization. In the normal script, you define the variable as "OnKeyPress", but you try to access it with "onKeyPress". You have to make them the same spelling and capitalization.
Thanks ill try and fix that now :)
Did that work?