I'm making a game and I have keybinds. I currently only have one action, punch. It works on computer but not on console. Can someone help me. Thanks in Advance
First off, I have a Local script in Starter gui
local uis = game:GetService("UserInputService")
local remote = game.ReplicatedStorage:WaitForChild("PunchRemote")
local plrgui = script.Parent
local setngs = plrgui:WaitForChild("Settings")
local KeyReq = setngs:WaitForChild("Key")
local frame = setngs:WaitForChild("Frame")
local button = frame:WaitForChild("PunchBtn")
local activating = false
local ConSetngs = plrgui:WaitForChild("Settings")
local ConOpen = ConSetngs:WaitForChild("Open")
local ConKeyReq = setngs:WaitForChild("Key")
local Conframe = setngs:WaitForChild("Frame")
local Conbutton = frame:WaitForChild("PunchBtn")
if uis.KeyboardEnabled then
if setngs.Open.Value == false then
uis.InputBegan:Connect(function(input, gameProcessedEvent)
if activating == false then
activating = true
tostring(input.KeyCode)
tostring(Enum.KeyCode[KeyReq.Value])
if input.KeyCode == Enum.KeyCode[KeyReq.Value] then
remote:FireServer()
else
print('NotEqual')
end
end
end)
uis.InputEnded:Connect(function(input, gameProcessedEvent)
print("Ended")
wait(1)
activating = false
end)
elseif uis.GamepadEnabled then
if ConSetngs.Open.Value == false then
uis.InputBegan:Connect(function(input, gameProcessedEvent)
if activating == false then
activating = true
tostring(input.KeyCode)
tostring(Enum.KeyCode[ConKeyReq.Value])
if input.KeyCode == Enum.KeyCode[ConKeyReq.Value] then
remote:FireServer()
end
end
end)
uis.InputEnded:Connect(function(input, gameProcessedEvent)
print("Ended")
wait(1)
activating = false
end)
end
end
end
Next I have a Local script in a button inside a frame inside a gui
local UserInputService = game:GetService("UserInputService")
local KeyStroke = Enum.KeyCode.V --// KeyStroke
local button = script.Parent
button.MouseButton1Click:Connect(function(player)
if UserInputService.GamepadEnabled then
UserInputService.InputBegan:Connect(function(input, GameProcessed)
if (input == KeyStroke ) then
else
if script.Parent.Parent.Parent.Open.Value == true then
local keycode = input.KeyCode
local keycodeStr = tostring(keycode)
print(keycode)
print(keycodeStr)
if keycodeStr == 'Enum.KeyCode.ButtonA' or keycodeStr == 'Enum.KeyCode.ButtonSelect' or keycodeStr == 'Enum.KeyCode.ButtonStart' then
print('Unkown KeyCode')
else
button.Parent.Parent.Key.Value = string.gsub(keycodeStr, "Enum.KeyCode.", "")
button.Text = string.gsub(keycodeStr, "Enum.KeyCode.Button", "")
end
end
end
end)
end
end)
Finally I have a script in ServerScriptService
local remote = Instance.new("RemoteEvent")
remote.Name = "PunchRemote"
remote.Parent = game:GetService("ReplicatedStorage")
game.Players.PlayerAdded:Connect(function(player)
player.CharacterAdded:Connect(function(char)
local humanoid = char:WaitForChild("Humanoid")
local animate = char:WaitForChild("Animate")
local animHold = Instance.new("StringValue")
animHold.Name = "Punch"
animHold.Parent = animate
local anim = Instance.new("Animation")
anim.Parent = animHold
anim.AnimationId = 'http://www.roblox.com/asset/?id=2889390323'
end)
end)
remote.OnServerEvent:Connect(function(player)
local humanoid = player.Character:WaitForChild("Humanoid")
local anim = player.Character:WaitForChild("Animate"):WaitForChild("Punch"):WaitForChild("Animation")
local animTrack = humanoid:LoadAnimation(anim)
print('playing')
animTrack:Play()
wait(1)
animTrack:Stop()
print("Punch")
end)
Remember it's just on console it won't work
