-
I want to achieve something like this.
-
The issue is the physics isnt doing what i want it to do
- Ive tried different settings to get it to work.
local SwingRemote = game.ReplicatedStorage.GameMechanics.Remotes.Swing
local ToolModelsFolder = game.ReplicatedStorage.GameMechanics.ToolModels
SwingRemote.OnServerEvent:Connect(function(player, delete, toolname)
local tool = ToolModelsFolder:FindFirstChild(toolname)
if delete == false then
for i,v in pairs(game.ReplicatedStorage.GameMechanics.ToolModels:GetDescendants()) do
if v.Name == tool.Name then
local Attachment = Instance.new("Attachment")
Attachment.Parent = player.Character:FindFirstChild("UpperTorso")
Attachment.Name = "SwingAttach"
Attachment.CFrame = CFrame.new(0.5, 0.5, 0.5)
Attachment.CFrame = CFrame.new(-90, -90, 0)
print(Attachment.Parent)
local Attachment2 = Instance.new("Attachment")
Attachment2.Parent = player.Character:FindFirstChild("UpperTorso")
Attachment2.Name = "SwingAttach2"
Attachment2.CFrame = CFrame.new(0.5, 0.5, 0.7)
local cloned = tool:Clone()
cloned.Parent = player.Character:FindFirstChild("UpperTorso")
local parte = cloned:FindFirstChild("AttachmentPart")
parte.Anchored = true
print(cloned.Parent)
local weld = Instance.new("CylindricalConstraint")
weld.Parent = cloned:FindFirstChild("AttachmentPart")
weld.LimitsEnabled = true
weld.UpperLimit = 0.3
weld.Attachment0 = Attachment
weld.Attachment1 = Attachment2
local model = cloned
local main = model:FindFirstChild("AttachmentPart")
for _, child in ipairs(model:GetChildren()) do
if child:IsA("BasePart") then
if child ~= main then
local weld = Instance.new("WeldConstraint")
weld.Part0 = main
weld.Part1 = child
weld.Parent = child
end
end
if child:IsA("MeshPart") then
if child ~= main then
local weld = Instance.new("WeldConstraint")
weld.Part0 = main
weld.Part1 = child
weld.Parent = child
end
end
end
end
end
end
end)
SwingRemote.OnServerEvent:Connect(function(player, delete, toolname) -- delete part
if delete == true then
task.wait(0.1)
local tool = player.Character.UpperTorso:FindFirstChild(toolname)
local swing = player.Character.UpperTorso.SwingAttach
local swing2 = player.Character.UpperTorso.SwingAttach2
tool:Destroy()
swing:Destroy()
swing2:Destroy()
end
end)
Server Script ^
local tool = script.Parent
local remote = game.ReplicatedStorage.GameMechanics.Remotes:FindFirstChild("Swing")
local delete = false
tool.Unequipped:Connect(function()
if delete == false then
local toolname = tool.Name
remote:FireServer(delete, toolname)
task.wait(0.1)
delete = true
end
end)
tool.Equipped:Connect(function()
if delete == true then
local toolname = tool.Name
remote:FireServer(delete, toolname)
task.wait(0.1)
delete = false
end
end)
Client Script/ Handler ^
Other stuff