Hey there!
I have a ragdoll game that I’m making, and I want it to be available to XBox users, along with PC. The problem is, I can’t figure out how to get the user inputs to work simultaneously for both devices. Here’s my PC script:
local character = script.Parent
local humanoid = character.Humanoid
game:GetService("ContextActionService"):BindAction("Ragdoll me", function(_,input)
if input == Enum.UserInputState.Begin then
local setEnabled = humanoid:GetState() ~= Enum.HumanoidStateType.Physics
humanoid:ChangeState(setEnabled and Enum.HumanoidStateType.Physics or Enum.HumanoidStateType.GettingUp)
character.Animate.Disabled = setEnabled
if setEnabled then
for _,v in pairs(humanoid:GetPlayingAnimationTracks()) do
v:Stop(0)
end
end
end
end, false, Enum.KeyCode.R)
And I’ve tried changing the KeyCode to ButtonX, but that either works only for XBox players, or not at all. I’ve even tried making a duplicate script for XBox. Same result. Only one device could ragdoll.
Any and all help is appreciated!
local character = script.Parent
local humanoid = character.Humanoid
game:GetService("ContextActionService"):BindAction("Ragdoll me", function(_,input)
if input == Enum.UserInputState.Begin then
local setEnabled = humanoid:GetState() ~= Enum.HumanoidStateType.Physics
humanoid:ChangeState(setEnabled and Enum.HumanoidStateType.Physics or Enum.HumanoidStateType.GettingUp)
character.Animate.Disabled = setEnabled
if setEnabled then
for _,v in pairs(humanoid:GetPlayingAnimationTracks()) do
v:Stop(0)
end
end
end
end, false, Enum.KeyCode.R or Enum.KeyCode.ButtonX)
local character = script.Parent
local humanoid = character.Humanoid
local UIS = game:GetService("UserInputService")
UIS.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.F then
print("yes")
elseif input.KeyCode == Enum.KeyCode.ButtonA then
print("yes")
end
end)
I added the code into those, but whenever I press the key, my avatar fell rigid, instead of ragdoll, free-limb. (If you could call it that, I suppose.)
What I like to do is have a “keybinds” table, and then unpack it when binding an action.
This allows me to easily add multiple inputs, and know what are an said actions inputs by looking at the code.