xxxxxxxxxx
class WatchedKey:
def __init__(self, key):
self.key = key
self.down = False
turtle.onkeypress(self.press, key)
turtle.onkeyrelease(self.release, key)
def press(self):
self.down = True
def release(self):
self.down = False
# You can now create the watched keys you want to be able to check:
a_key = WatchedKey('a')
b_key = WatchedKey('b')
# and you can check their state by looking at their 'down' attribute
a_currently_pressed = a_key.down
xxxxxxxxxx
import turtle
class WatchedKey:
def __init__(self, key):
self.key = key
self.down = False
turtle.onkeypress(self.press, key)
turtle.onkeyrelease(self.release, key)
def press(self):
self.down = True
def release(self):
self.down = False
# You can now create the watched keys you want to be able to check:
a_key = WatchedKey('a')
b_key = WatchedKey('b')
# and you can check their state by looking at their 'down' attribute
a_currently_pressed = a_key.down
xxxxxxxxxx
local uis = game:GetService("UserInputService")
local rp = game:GetService("ReplicatedStorage")
local spaceHeld = uis:IsKeyDown(Enum.KeyCode.E)
local attack = rp:WaitForChild("attack")
uis InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
attack:FireServer()
end
end)
attack.OnClientEvent:Connect(function(HumanoidRootPart)
local function inputBegan(object,gameProcessedEvent)
if HumanoidRootPart.IsKeyDown == spaceHeld then
print("Player pressed space!!1!")
end
end
uis.InputBegan:Connect(inputBegan)
end)