So I'm trying to make a Kamehameha, for some reason, the ball that appears in your hand never gets deleted when the move is fired. I figured out, active is gets set to false but it gets set back to true immediately after.
-- Local Script
local player = game.Players.LocalPlayer
local mouse = player:GetMouse()
local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local freeze = game.ReplicatedStorage:WaitForChild("freeze")
local active1 = true
local uis = game:GetService("UserInputService")
local part1 = true
local part2 = true
local KeyDown = false
local size = 0
local i = 20
function reset() -- Resets Variables
i = 20
size = 0
active1 = true
part1 = true
part2 = true
end
uis.InputBegan:connect(function(inst) -- Detects input
if inst.KeyCode == Enum.KeyCode.Q then -- Detects if the input is Q
if part1 == true then -- Debounce? I don't know if that's the right word but it makes this part not run until this value is true
part1 = false
KeyDown = true
local localplayer = game.Players.LocalPlayer
local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent:FindFirstChild("kameload")) -- Loads Animation
animation:Play() -- Plays Animation
freeze:FireServer(localplayer, active1) -- Fires event to make ball and slowly increase size
while KeyDown do
i = i - 1
if KeyDown == true then
wait(0.2)
size = size + 1
elseif KeyDown == false then
active1 = false
break
end
if i == 1 then
KeyDown = false
active1 = false
break
end
end
end
end
end)
uis.InputEnded:connect(function(inst) -- Detects input ending
if inst.KeyCode == Enum.KeyCode.Q then -- Detects if q is not longer being inputted
if part2 == true then
part2 = false -- Disables this script
local localplayer = game.Players.LocalPlayer
KeyDown = false
active1 = false
freeze:FireServer(localplayer, active1) -- Changes active value to shut off remote
local animation = game.Players.LocalPlayer.Character.Humanoid:LoadAnimation(script.Parent:FindFirstChild("kamefire")) -- Animation
game.ReplicatedStorage.RemoteEvent:FireServer(localplayer, size)
wait(0.1)
animation:Play()
wait(7)
reset() -- Runs reset function
end
end
end)
-- Server Script
local remote = game.ReplicatedStorage:WaitForChild("RemoteEvent")
local freeze = game.ReplicatedStorage:WaitForChild("freeze")
function kame(player, localplayer, character, size)
local length = 5 -- This will be the length of the attack
local place = 5 -- The offset for how far ahead the attack will be
local noMove = length / 2 -- Don't touch this
local atkTime = 0.1 -- The rate at which the attack dissapates
local transRemove = 0.1 -- The rate at which transperancy increases
local ballNoMove = length / 2
local copy = game.ServerStorage.kame:Clone()
local wave = copy:FindFirstChild("wave")
local ball = copy:FindFirstChild("ball")
local torso = localplayer.Character.UpperTorso
wave.CFrame = torso.CFrame + torso.CFrame.lookVector * place
ball.CFrame = wave.CFrame * CFrame.new(0, 0, -4)
wave.Orientation = wave.Orientation + Vector3.new(90, 0, 0)
wave.Size = wave.Size + Vector3.new(size, 0, size)
ball.Size = wave.Size + Vector3.new(size, size, size)
copy.Parent = game.Workspace
for i = 20, -100, -1 do
wait(0.1)
print("working")
place = place + noMove
ballNoMove = ballNoMove + 2.5
wave.Size = wave.Size + Vector3.new(0, length, 0)
wave.CFrame = torso.CFrame + torso.CFrame.lookVector * place
wave.Orientation = wave.Orientation + Vector3.new(90, 0, 0)
ball.CFrame = wave.CFrame * CFrame.new(0, -ballNoMove, 0)
if i < 11 then
ball.Transparency = ball.Transparency + transRemove
wave.Transparency = wave.Transparency + transRemove
print(wave.Transparency)
end
if wave.Transparency > 1 then
ball:Destroy()
wave:Destroy()
break
end
end
for i=1, #character do
if character[i].ClassName == "Part" then
character[i].Anchored = false
end
end
localplayer.Character.Humanoid.WalkSpeed = 16
end
function kameload(player, localplayer, active1) -- function for ball
local bal1Load = game.ServerStorage.kame.ball:Clone()
local torso = localplayer.Character.LeftHand
bal1Load.CFrame = torso.CFrame + torso.CFrame.lookVector
bal1Load.Parent = game.Workspace
while true do
print(active1)
if active1 == true then
wait(0.5)
bal1Load.Size = bal1Load.Size + Vector3.new(0.025, 0.025, 0.025)
bal1Load.CFrame = torso.CFrame + torso.CFrame.lookVector
elseif active1 == false then
print("yes")
bal1Load:Destroy()
bal1Load = nil
break
end
end
end
freeze.OnServerEvent:Connect(function(player, localplayer, active1) -- freeze remote
localplayer.Character.Humanoid.WalkSpeed = 0
localplayer.Character.Humanoid.JumpPower = 0
kameload(player, localplayer, active1)
end)
remote.OnServerEvent:Connect(function(player, localplayer, size)
localplayer.Character.Humanoid.WalkSpeed = 0
localplayer.Character.Humanoid.JumpPower = 0
local character = game.Workspace:FindFirstChild(localplayer.Name):GetChildren()
wait(0.1)
for i=1, #character do
if character[i].ClassName == "Part" then
character[i].Anchored = true
end
end
wait(0.5)
kame(player, localplayer, character, size)
end)
Any help would be appreciated, thanks!
