Trying to make this work but no work

What im trying to do: make player freeze and unfreeze after a certain amount of time after pressing E

script:
local PlayerMod = require (game:GetService(“Players”).LocalPlayer.PlayerScripts:WaitForChild(“PlayerModule”))
local Controls = PlayerMod:GetControls()
local uis = game:GetService(“UserInputService”)
local db = false
uis.InputBegan:Connect(function(Input)
if Input.UserInputType == Enum.KeyCode.E and not db then
db = true
Controls:Disable()
wait(5)
db = false
Controls:Enable()
end
end)

any help is appreciated :DD

1 Like
local PlayerMod = require(game:GetService("Players").LocalPlayer.PlayerScripts:WaitForChild("PlayerModule"))
local Controls = PlayerMod:GetControls()
local uis = game:GetService("UserInputService")
local db = false

uis.InputBegan:Connect(function(Input)
	if Input.KeyCode == Enum.KeyCode.E and not db then
		db = true
		Controls:Disable()
		wait(5)
		db = false
		Controls:Enable()
	end
end)

Before you were attempting to compare a UserInputType enumeration with a KeyCode enumeration.

1 Like