Here are the scripts.
Local Script - RemoteEvent controller
local remoteEvent = script.Parent:WaitForChild("RemoteEvent")
local mouse = game.Players.LocalPlayer:GetMouse()
script.Parent.Activated:Connect(function()
remoteEvent:FireServer(mouse.Hit.Position)
end)
Main Script
local Cooldown = false
local Model = script.Parent.Bone:Clone()
local tool = script.Parent
local name = tool.Name
local CD = 8
local count = 20
local function ISTRUE()
local player = script.Parent.Parent
local hrp = player:FindFirstChild("HumanoidRootPart")
tool.Activated:Connect(function()
if Cooldown == false then
Cooldown = true
local part = Instance.new("Part", hrp)
part.Massless = true
part.CollisionGroup = "Attacks"
part.Size = Vector3.new(4,1,4)
part.Color = Color3.fromRGB(255,0,0)
part.Transparency = 0.5
part.Position = hrp.Position
part.CanCollide = false
part.CanTouch = false
part.CanQuery = false
local motorWeld = Instance.new("Motor6D", hrp)
motorWeld.Part0 = hrp
motorWeld.Part1 = part
local Weld = Instance.new("Weld", hrp)
Weld.Part0 = hrp
Weld.Part1 = part
local spinningthread = task.spawn(function()
while task.wait(0.05) do
Weld.C0 = Weld.C0 * CFrame.fromEulerAnglesXYZ(0,0.35,0)
end
end)
repeat
local Gb = Model:Clone()
local boneWeld = Instance.new("Weld", part)
boneWeld.Part0 = part
boneWeld.Part1 = Gb
Gb.Anchored = false
boneWeld.C0 = boneWeld.C0 * CFrame.Angles(0,math.rad(-90),0)
boneWeld.C0 = boneWeld.C0 + Vector3.new(35,0,0)
--Gb.Script.Enabled = true
Gb.Owner.Value = player.Parent.Name
Gb.Parent = workspace.Attacks
Gb.Massless = true
local thread = task.spawn(function()
local tween = tS:Create(Gb,TweenInfo.new(0.5,Enum.EasingStyle.Linear,Enum.EasingDirection.In),{Transparency = 0})
tween:Play()
tween.Completed:Wait()
tween:Cancel()
end)
task.wait(0.05)
count -= 1
task.cancel(thread)
until count == 0
tool.RemoteEvent.OnServerEvent:Connect(function(P, Pos) end)
task.cancel(spinningthread)
local NewCD = CD
repeat
tool.Name = NewCD
task.wait(0.1)
NewCD = (math.round((NewCD - 0.1) * 100) / 100)
until NewCD <= 0
tool.Name = name
Cooldown = false
count = 20
end
end)
end
tool.Equipped:Connect(ISTRUE)
For context, I’m trying to make a attack where meshparts will orbit around the player using a new part that is welded onto the player and all the parts that are cloned in the process will cover the player’s horonzontal direction. Essentially, this means that all 20 cloned “Bone” parts covers the entire player, almost as if there are nearby orbitting parts. After clicking again, the parts will destroy all welds and face the direction the player pointed at, before going towards that direction.
Here’s my issues. There are two of them. The first one has to do with the orbitting part. When I try and make the orbit, all the parts just clone in the same position the part that welds all the clones together is facing. I want to be able to make it so that the parts orbit all around the part it is welded on, like all the parts are covering each direction on the X/Z axis.
The 2nd issue has to do with the remoteEvent. I do not know how to make a more efficient method of triggering the tool once again without making it so that when I click once, the remoteEvent is instantly triggered and the tool is rendered useless. In basic terms, I want it so that when the player clicks once, the parts orbit all around the player and when they use the tool twice, the remoteEvent fires off this time and the parts attack any enemy in the direction the player pointed their mouse towards.
These are the only 2 issues. If anyone would like to help, please do so!
Oh and, I’ve already tried WeldConstraint. It doesn’t do much of a better job.