So… I’m trying to make a Ball Attack that go to where the mouse is, and if the ball touch any wall, the ball is deleted.
When the Ball is spawned, it go to a random place and not to where the mouse is.
I don’t know what to do, is anything wrong with my script?
This script is inside ServerScriptService
Events.Hasty.Shadow.ShadowQ.OnServerEvent:Connect(function(Player, Mouse)
local ShadowBall = Attacks.Hasty.Shadow.ShadowQ:Clone()
ShadowBall.CFrame = Player.Character:FindFirstChild("HumanoidRootPart").CFrame * CFrame.new(0,0,-3)
ShadowBall.Parent = game.Workspace
ShadowBall.Anchored = false
local PlayerAttacking = Instance.new("StringValue")
PlayerAttacking.Parent = ShadowBall
PlayerAttacking.Name = "PlayerAttacking"
PlayerAttacking.Value = Player.Name
local TweenTransparency = TweenService:Create(ShadowBall, TweenInfo.new(0.25), {Transparency = 1})
local HRP = Player.Character:FindFirstChild("HumanoidRootPart")
local LinearVelocity = ShadowBall.Attachment.LinearVelocity
LinearVelocity.MaxForce = math.huge
LinearVelocity.VectorVelocity = HRP.CFrame.LookVector * 50
wait(3)
if ShadowBall then
TweenTransparency:Play()
wait(0.25)
ShadowBall:Destroy()
end
end)
This one is in StarterCharacterScripts
UIS.InputBegan:Connect(function(input)
if (UIS:GetFocusedTextBox()) then
return
end
if input.KeyCode == Enum.KeyCode.Q and dbQ then
dbQ = false
local Mouse = game.Players.LocalPlayer:GetMouse()
game.ReplicatedStorage.Attacks.Hasty.Shadow.ShadowQ:FireServer(Mouse.Hit.LookVector)
wait(3)
dbQ = true
end
end)
This script is inside the ball
local ShadowBall = script.Parent
local db = true
ShadowBall.Touched:Connect(function(Hit)
if Hit.Name == "HitBox" and db then
db = false
local Enemy = Hit.Parent
local Damage = (game.Players:FindFirstChild(script.Parent:FindFirstChild("PlayerAttacking").Value):FindFirstChild("Stats"):FindFirstChild("SubDamage").Value*1.5) - Enemy:FindFirstChild("Defense").Value
if Damage <= 0 then
Damage = 1
end
Enemy.Health.Value = Enemy.Health.Value - Damage
script.Parent:Destroy()
end
end)
The Ball should spawn in front of the Player when Q is press and go to where the mouse is, if hit an Enemy, it damage the enemy, but if hit a wall, the ball is destroyed.