Hello, I Am making A Boogie Woogie Spec, And im on the actual switching part, but Im having trouble with getting it to work 100% of the time. so basically what is happening Is that the First switch is fine, but the Second Switch After Using The Ability Once Just Doesnt Work, I have Turned off Cooldown In The Video Below So that Is Be Understood More Easily:
local script:
game.UserInputService.InputBegan:Connect(function(input)
if input.KeyCode == Enum.KeyCode.E then
if stun == false then
stun = true
if mouse.Target then
if mouse.Target.Parent:FindFirstChild("Humanoid") then
bf = true
EAbility:Play()
EAbility:GetMarkerReachedSignal("HIT"):Connect(function()
script["Clap Sound"].PlaybackSpeed = 1 + (math.random(0,5)/10)
script["Clap Sound"]:Play()
task.wait(0.1)
local root2 = mouse.Target.Parent.HumanoidRootPart
cooldown:FireServer("Clap", ECooldownAmount)
AttackRE:FireServer("Switch", root, root2)
end)
end
end
task.wait(EAbility.Length + 0.2)
EAbility:Destroy()
stun = false
elseif stun == true then
bf = false
stun = false
end
end
end)
server script:
local rs = game:GetService("ReplicatedStorage")
local Remotes = rs:FindFirstChild("Remotes")
local AttackRE = Remotes:FindFirstChild("Attack")
AttackRE.OnServerEvent:Connect(function(Player,Type,Var1,Var2)
if Type == "Switch" then
local part1 = Instance.new("Part", workspace)
part1.CFrame = Var1.CFrame
part1.Size = Vector3.new(1,1,1)
part1.Transparency = 1
part1.Anchored = true
part1.CanCollide = false
local part2 = Instance.new("Part", workspace)
part2.Size = Vector3.new(1,1,1)
part2.Transparency = 1
part2.Anchored = true
part2.CanCollide = false
part2.CFrame = Var2.CFrame
Var2.CFrame = part1.CFrame
Var1.CFrame = part2.CFrame
part1:Destroy()
part2:Destroy()
end
end)