-
What do you want to achieve? I want to make a wand that can shoot out fireballs that would deal damage.
-
What is the issue? When I used the wand script only the fireballs would shoot but with no damage. When I added a script to the fireball to deal damage the fireball wouldn’t even come out.
-
What solutions have you tried so far? Looked on devforum and looked on yt. Reread and edited my code.
WandScript:
local Debris = game:GetService(“Debris”)
local debounce = true
script.Parent.Activated:Connect(function()
if debounce then
debounce = false
local fireball = game.ServerStorage.FireBall:Clone()
fireball.Owner.Value = script.Parent.Parent.Name
fireball.Damage.Value = script.Parent.Damage.Value
fireball.CFrame = CFrame.new(script.Parent.Handle.Position)
fireball.BodyPosition.Position = Vector3.new(0, script.Parent.Handle.Position.Y, 0)
fireball.BodyForce.force = script.Parent.Parent.HumanoidRootPart.CFrame.LookVector* script.Parent.Speed.Value
fireball.Parent = game.Workspace
Debris:AddItem(fireball, 5)
wait(script.Parent.CoolDown.Value)
debounce = true
end
end)
FireBallScript:
script.Parent.Touched:Connect(function(hit)
if hit.Parent:FindFirstChild(“Humanoid”) then
if hit.Parent.Name ~= script.Parent.Owner.Value then
hit.Parent.Humanoid:TakeDamage(script.Parent.Damage.Value)
script.Parent:Destroy()
end
else
if hit.Parent.Name ~= script.Parent.Name and hit.Parent.Name ~= script.Parent.Owner.Value then
script.Parent:Destroy()
end
end
end)
If you spot any errors please respond below. Thank you for reading this and if you helped also thank you!
Edit: Experiments later I figured out that the wand acted as a sword… Can someone explain why and how to fix it please? Thank you.
is the fireball anchored? that could explain why it is not moving after being spawned making it act like a sword. Or the bodyforce value could be too low to make it move.
1 Like
Fireball Is not anchored. Though the body force is low… what is a good body force?
Edit: Changed the fireball BodyForce to 0, 5000, 0 still doesn’t work.
Try changing that bodyforce to a bodyvelocity and setting the velocity. That should give the outcome you are looking for.
try setting the force to the lookvector * 5000
Nope it didn’t work. Should I keep the velocity or change it back to body force?
is the wand script on the server or the client?
It is a server script so I think it is on the server.
fireball.BodyPosition.Position = Vector3.new(0, script.Parent.Handle.Position.Y, 0)
is this line setting a position of a part or a BodyPosition Constraint? That could be a problem because it would be bringing the fireball back to the wand position constantly.
What its doing is it will set the position of the fireball to the torso and wherever the player is looking at for example, torso position + wherever player is looking at = fireball direction. I don’t know if it is being looped somehow…
Yes it is that instance @scripted_pj.
I had to ping you because it had to be longer than you know how long sorry!
Edit: roblox won’t let me right the amount of characters a text/reply must be
I think what is happening is that the fireball is being teleported to my torso and when my torso hits the enemy it attacks the enemy. Which would explain the sword like behavior.
all good.
ok so i assume u have this because the fireball was falling because only a force was being applied to it. What it is doing is moving the part to Vector3.new(0, script.Parent.Handle.Position.Y, 0). This is overriding the body force u have applied. I would recommend getting rid of the body force and position and just using body velocity.
Try setting the body velocity to Vector3.new(0,0,-10). I think the goal vector is applied in object space but I’m not sure. The body velocity will prevent the ball from having the effects of gravity as well.
Still doesn’t work here is my code
script.Parent.Activated:Connect(function()
if debounce then
debounce = false
local fireball = game.ServerStorage.FireBall:Clone()
fireball.Owner.Value = script.Parent.Parent.Name
fireball.Damage.Value = script.Parent.Damage.Value
fireball.CFrame = CFrame.new(script.Parent.Handle.Position)
fireball.BodyVelocity.MaxForce = script.Parent.Parent.HumanoidRootPart.CFrame.LookVector * script.Parent.Speed.Value
fireball.Parent = game.Workspace
Debris:AddItem(fireball, 5)
wait(script.Parent.CoolDown.Value)
debounce = true
end
end)
Only have a body Velocity
You have to set the BodyVelocity.Velocity . Sorry i should have mentioned that. Changing the force changes how much force can be applied which affects the acceleration to said velocity.
Like this?
local Debris = game:GetService(“Debris”)
local debounce = true
script.Parent.Activated:Connect(function()
if debounce then
debounce = false
local fireball = game.ServerStorage.FireBall:Clone()
fireball.Owner.Value = script.Parent.Parent.Name
fireball.Damage.Value = script.Parent.Damage.Value
fireball.CFrame = CFrame.new(script.Parent.Handle.Position)
fireball.BodyVelocity.Velocity = script.Parent.Parent.HumanoidRootPart.CFrame.LookVector * script.Parent.Speed.Value
fireball.Parent = game.Workspace
Debris:AddItem(fireball, 5)
wait(script.Parent.CoolDown.Value)
debounce = true
end
end)
Btw I set BodyVelocity to 0, 0, -10
This won’t work.
is the fireball moving at all? or is it just stuck where it spawns?
Its invisible to me. But I think it is moving bc I moved a test dummy when I fired a fireBall. Is it Invisible bc I put it in serverstorage instead of rep storage?