Hello! I am trying to make a shockwave tool that un-anchors all parts that it touches. With my current code it is not un-anchoring the parts even though all the prints go off.
local TweenService = game:GetService("TweenService")
game.ReplicatedStorage.FireHammer.OnServerEvent:Connect(function(Player)
local ShockPos = Player.Character:FindFirstChild("Head")
local ShockPart = Instance.new("Part")
ShockPart.Position = ShockPos.Position + Vector3.new(0, 2, 0)
ShockPart.Shape = Enum.PartType.Ball
ShockPart.Anchored = true
ShockPart.Transparency = 0.2
ShockPart.CanCollide = false
ShockPart.CanTouch = true
ShockPart.Material = Enum.Material.Neon
ShockPart.Color = Color3.new(1, 0.784314, 0)
ShockPart.Parent = game.Workspace
ShockPart.Touched:Connect(function(hit)
if hit.ClassName == "Part" or hit.ClassName == "MeshPart" then
hit.Anchored = false
print("Unanchored part "..hit.Name.."!")
else
for i , v in pairs(hit:GetDescendants()) do
v.Anchored = false
end
print("Unanchored descendants of "..hit.Name.."!")
end
end)
local Tween = TweenInfo.new(1, Enum.EasingStyle.Linear, Enum.EasingDirection.Out)
local Tween1 = TweenService:Create(ShockPart, Tween, {
Size = Vector3.new(200, 200, 200)
})
Tween1:Play()
wait(3)
local Tween2 = TweenInfo.new(5)
local Tween3 = TweenService:Create(ShockPart, Tween2, {
Transparency = 1
})
Tween3:Play()
wait(5)
ShockPart:Destroy()
end)
If anyone is curious the LocalScript that fires the event is this,
script.Parent.Activated:Connect(function()
game.ReplicatedStorage.FireHammer:FireServer()
end)