local module
local module = {}
-- //Services
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- //Folder
local RemoteEvents = ReplicatedStorage:FindFirstChild("RemoteEvents")
-- //Remotes
local UnreliableWeld = RemoteEvents:FindFirstChild("UnreliableWeld")
function module:input(player, character)
-- //BaseParts
local RightDigit = character:FindFirstChild("Right Digit")
local LeftDigit = character:FindFirstChild("Left Digit")
-- //Humanoid
local Humanoid = character:FindFirstChild("Humanoid")
local Animator = Humanoid:FindFirstChild("Animator")
local RightAnimation = Animator:LoadAnimation(script:FindFirstChild("RightAnimation"))
local LeftAnimation = Animator:LoadAnimation(script:FindFirstChild("LeftAnimation"))
RightAnimation:Play()
LeftAnimation:Play()
-- //Debounce
local RDebounce = false
local LDebounce = false
-- //Variables
local RPart
local LPart
UserInputService.InputBegan:Connect(function(input: InputObject, gameProcessedEvent: boolean)
if input.KeyCode == Enum.KeyCode.ButtonR1 or input.KeyCode == Enum.KeyCode.ButtonR2 then
if not RDebounce then
RDebounce = true
RPart = RightDigit:GetTouchingParts()
print(#RPart, RPart)
UnreliableWeld:FireServer(RDebounce, RPart)
end
elseif input.KeyCode == Enum.KeyCode.ButtonL1 or input.KeyCode == Enum.KeyCode.ButtonL2 then
if not LDebounce then
LDebounce = true
LPart = LeftDigit:GetTouchingParts()
UnreliableWeld:FireServer(LDebounce, LPart)
end
end
end)
UserInputService.InputEnded:Connect(function(input: InputObject, gameProcessedEvent: boolean)
if input.KeyCode == Enum.KeyCode.ButtonR1 or input.KeyCode == Enum.KeyCode.ButtonR2 then
if RDebounce then
RDebounce = false
UnreliableWeld:FireServer(RDebounce, RPart)
end
elseif input.KeyCode == Enum.KeyCode.ButtonL1 or input.KeyCode == Enum.KeyCode.ButtonL2 then
if LDebounce then
LDebounce = false
UnreliableWeld:FireServer(LDebounce, LPart)
end
end
end)
end
return module
server module
local module = {}
-- //Services
local UserInputService = game:GetService("UserInputService")
local ReplicatedStorage = game:GetService("ReplicatedStorage")
-- //Folder
local RemoteEvents = ReplicatedStorage:FindFirstChild("RemoteEvents")
-- //Remotes
local UnreliableWeld = RemoteEvents:FindFirstChild("UnreliableWeld")
-- //
local partBound = {
["Right Digit"] = nil,
["Left Digit"] = nil
}
UnreliableWeld.OnServerEvent:Connect(function(player: Player, RDebounce, RPartTable, LDebounce, LPartTable)
-- //Character
local character = player.Character
-- //Digits
local RightDigit = character:FindFirstChild("RightDigit")
local LeftDigit = character:FindFirstChild("Left Digit")
if partBound["Right Digit"] ~= nil and RDebounce then
return
end
if partBound["Left Digit"] ~= nil and LDebounce then
return
end
for _, R in pairs(RPartTable) do
if RDebounce then
if partBound["Right Digit"] == nil then
if R then
partBound["Right Digit"] = R.Name
-- //Weld
local Weld = Instance.new("WeldConstraint", RightDigit)
Weld.Part0 = RightDigit
Weld.Part1 = R
if R.Name == "Right Arm" then
-- //LineForce
if not RightDigit:FindFirstChildWhichIsA("LineForce") then
local LineForce = Instance.new("LineForce", RightDigit)
LineForce.Attachment0 = R:FindFirstChild("RightGripAttachment")
LineForce.Attachment1 = RightDigit:FindFirstChildWhichIsA("Attachment")
LineForce.ReactionForceEnabled = true
end
end
end
end
elseif not RDebounce then
partBound["Right Digit"] = nil
if RightDigit:FindFirstChild("LineForce") then
-- //LineForce
local LineForce = RightDigit:FindFirstChild("LineForce")
LineForce.Parent = nil
end
if RightDigit:FindFirstChildWhichIsA("WeldConstraint") then
local Weld = RightDigit:FindFirstChild("WeldConstraint")
Weld:Destroy()
end
if table.find(partBound["Right Digit"], R.Name) then
table.remove(R)
end
end
end
end)
return module