So i’m recreating the magneto stick from Garry’s Mod TTT
So far i’m doing pretty well but i’ve ran into an issue.
It uses ball socket constraints to do the telekinesis part but its a --little-- bit buggy
heres an image of how its set up
The red is the part that the enemy player/ragdoll is Ball socketed too. It was previously a weld but i changed it for smoothness purposes
local arm1, arm2
local weld1, weld2
local torso
local mouse
local player = game:GetService("Players").LocalPlayer
local char = player.Character or player.CharacterAdded:Wait()
local h = char:WaitForChild("Humanoid")
mouse = player:GetMouse()
local target = mouse.Target
local tool = script.Parent
local p1 = char
local carry = tool.carry.Value
tool.Activated:Connect(function()
if player:GetMouse().Target and carry == false then
if player:GetMouse().Target.Parent:FindFirstChild('Humanoid') then
print('Humanoid located.')
--local chr = target
local p2 = mouse.Target.Parent:FindFirstChild("Torso")
game.ReplicatedStorage.Magneto:FireServer(p2.Parent:FindFirstChild('Humanoid'),p2)
local weldr = Instance.new("BallSocketConstraint", tool) do
weldr.Attachment0 = tool.HoldPart.ParticleAttachment
weldr.Attachment1 = p2.Parent.HumanoidRootPart.RootAttachment
end
wait()
carry = false
else
print('Couldn\'t find humanoid.')
end
else
print('Target is nil. Bruh')
end
end)
tool.Equipped:Connect(function()
local player = game:GetService("Players").LocalPlayer do
mouse = player:GetMouse()
local character = player.Character or player.CharacterAdded:wait()
torso = character:WaitForChild("Torso") do
arm2 = character:WaitForChild("Right Arm")
torso:WaitForChild("Right Shoulder").Part0 = nil
end
weld2 = Instance.new("Weld", torso) do
weld2.C0 = CFrame.new(1.5,.5,0)
weld2.Part0 = torso
weld2.Part1 = arm2
end
end
local tock = tick()
local offset = CFrame.new(0,0,-0.5)*CFrame.Angles(math.pi/2,0,0)
game:GetService("RunService"):BindToRenderStep("FPS_Arms", Enum.RenderPriority.First.Value, function()
arm2.LocalTransparencyModifier = 0
local p0c0 = torso:GetRenderCFrame()*weld2.C0
weld2.C1 = (CFrame.new(p0c0.p, mouse.Hit.p)*offset):inverse()*p0c0
tock = tick()
end)
end)
tool.Unequipped:Connect(function()
weld2:Destroy()
torso:WaitForChild("Right Shoulder").Part0 = torso
end)
This is the local script
local chr = player.Character or player.CharacterAdded:Wait()
chr:WaitForChild("Humanoid").BreakJointsOnDeath = false
game.ReplicatedStorage.rag:Fire(hum.Parent)
-- hum.Parent.Head.CanCollide = false
-- hum.Parent.Torso.CanCollide = false
end)
And this is the server script for the magneto remote.
I know there is something i’m missing to make it a lot more smooth. But i dont know what it is. If you guys can. Could you provide an edit of my code or a explanation of how to fix this? Thank you.