Hello, So I’m working on a slapping game and I’ve ran into a problem. I’m not sure if its the way I coded it but I see that the Part I use to make the Arm follow the mouse lag’s horribly. How could I fix this and make it look smoother.
Example:
Server:
MainEvent.OnServerEvent:Connect(function(LocalPlr,Action,Mouse)
-- Constants / Character --
local Character = LocalPlr.Character
local Humanoid = Character:FindFirstChild('Humanoid')
local Head = Character:FindFirstChild('Head')
local UpperTorso = Character:FindFirstChild('UpperTorso')
local RightLowerArm = Character:FindFirstChild('RightLowerArm')
local RightUpperArm = Character:FindFirstChild('RightUpperArm')
-- Check x2 --
if Action == 'Slapping' then
-- Constant --
local Walls = nil
local Part = nil
if not Character:FindFirstChild('Part') then
-- Constants --
Part = Instance.new('Part',Character)
local ArmControl = Instance.new('IKControl',Humanoid) ArmControl.Name = 'ArmControl'
local TorsoControl = Instance.new('IKControl',Humanoid) TorsoControl.Name = 'TorsoControl'
-- Setup Part --
Part.Size = Vector3.new(1,1,1)
Part.Anchored = true
Part.CanCollide = false
Part.Position = Vector3.new(Head.Position.X,Head.Position.Y + 2,Head.Position.Z + 10)
-- Set Settngs / ArmControl --
ArmControl.Type = Enum.IKControlType.Position
ArmControl.EndEffector = RightLowerArm
ArmControl.Target = Part
ArmControl.ChainRoot = RightUpperArm
-- Set Settngs / ArmControl --
TorsoControl.Type = Enum.IKControlType.LookAt
TorsoControl.EndEffector = UpperTorso
TorsoControl.Target = Part
TorsoControl.ChainRoot = UpperTorso
else
Part = Character:FindFirstChild('Part')
local ArmControl = Humanoid:FindFirstChild('ArmControl')
local TorsoControl = Humanoid:FindFirstChild('TorsoControl')
-- Set Settngs / ArmControl --
ArmControl.Type = Enum.IKControlType.Position
ArmControl.EndEffector = RightLowerArm
ArmControl.Target = Part
ArmControl.ChainRoot = RightUpperArm
-- Set Settngs / ArmControl --
TorsoControl.Type = Enum.IKControlType.LookAt
TorsoControl.EndEffector = UpperTorso
TorsoControl.Target = Part
TorsoControl.ChainRoot = UpperTorso
-- For Statement --
for _,Station in workspace.Map.Stations:GetDescendants() do
if Station:IsA('Model') and Station:GetAttribute('GameStarted',true) then
-- For Statement --
for _,Pad in Station.Queuing:GetChildren() do
if Pad.Name == 'TeamBlue' or Pad.Name == 'TeamRed' and Pad:GetAttribute('QueuedPlr',Character.Name) then
-- Debug --
Walls = Station:FindFirstChild('Prevention')
end
end
end
end
-- While Statement --
while Character:GetAttribute('Slapping',true) do
task.wait()
-- Check --
--if Mouse < Walls.Right.Position.X then
Part.Position = Vector3.new(Mouse,Part.Position.Y,Part.Position.Z)
--end
end
end
Client:
MainEvent.OnClientEvent:Connect(function(Action)
-- Check --
if Action == 'Slapping' then
-- While Statement --
while Character:GetAttribute('Slapping',true) do
task.wait()
-- Fire Event --
MainEvent:FireServer('Slapping',LocalMouse.Hit.X)
end
-- Check --
elseif Action == 'GetSlapped' then
MainEvent:FireServer('GetSlapped',LocalMouse.Hit.X)
end
end)