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)
I coudnt figure out whats the problem.
it just tell me: IsKeyDown is not a valid member of Part “Workspace.Iwantbebetter.HumanoidRootPart”
So for the FireClient (Server for Fire) I do have;
player.Character
player
Humanoid
HumanoidRootPart
and everything what I have been tested didnt work.
I think there is more than KeyCode because with KeyCode it didnt work too. I tried everything out ,and yea nothing worked. Can Somoene help me pls?
local uis = game:GetService("UserInputService")
local rp = game:GetService("ReplicatedStorage")
local attack = rp:WaitForChild("attack")
uis.InputBegan:Connect(function(input)
if (uis:GetFocusedTextBox()) then
return; -- make sure player's not chatting!
end
if input.KeyCode == Enum.KeyCode.F then
attack:FireServer()
end
end)
attack.OnClientEvent:Connect(function(HumanoidRootPart)
local OneTimeConnection = nil
local function inputBegan(object,gameProcessedEvent)
if (uis:GetFocusedTextBox()) then
return; -- make sure player's not chatting!
end
if (object.KeyCode == Enum.KeyCode.Space) then
print("Player pressed space!")
OneTimeConnection = OneTimeConnection and OneTimeConnection:Disconnect() or nil
end
end
OneTimeConnection = uis.InputBegan:Connect(inputBegan)
end)
InputBegan gives 2 params, first being input, second being boolean stating whether game processed that input already. If player is typing, it should be true. You can check it like so:
uis.InputBegan:Connect(function(inputObject: InputObject, gameProcessed:boolean)
if gameProcessed then return end -- If game processed, return instantly
--> Logic goes here...
end)