Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
0

Fire Ball Script Will Not Rotate The Front To The Right Position?

Asked by
LuaDLL 253 Moderation Voter
6 years ago
Edited 6 years ago

So, I am making a fireball script when a player press F and it works except for the rotation of the fireball, i want the rotation to be facing the same way the player is facing and I don't know what I did wrong here.

Script:

local plr = game.Players.LocalPlayer
local mouse = plr:GetMouse()
CanShoot = true
In = false

repeat wait() until plr.Character
local char = plr.Character

mouse.KeyDown:connect(function(key)
    if key == "f" then
        if CanShoot == true  and In == false then
            In = true
            CanShoot = false
            local part = Instance.new("Part")
            local fire = Instance.new("Fire",part)
            local Mesh = Instance.new("SpecialMesh",part)
            fire.Size = 3.4
            Mesh.MeshId = "rbxassetid://475201433"
            Mesh.Scale = Vector3.new(0.1,0.1,0.1)
            Mesh.TextureId = "rbxassetid://475201512"
            part.Parent = workspace
            part.Name = 'FireBall'
            part.CanCollide = false
            part.Anchored = true
            part.Position = plr.Character.Torso.Position
            local move = Instance.new("BodyVelocity", part)
            move.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
            move.Velocity = plr.Character.Torso.CFrame.lookVector*100
            wait(3)
            part:Destroy()
            CanShoot = true
            In = false
        end
    end
end)

The Problem Is At Line 26 And I Don't Know What I Did Wrong Here.

0
Please don't use mouse.KeyDown. It is deprectaed. You should use ContextActionService or UserInputService. Plus, connect is depricated, use Connect. Plus, if you remove the second argument of Instance.new, then do the properties, after that, do [instacnename].Parent = [instanceparent] saSlol2436 716 — 6y

1 answer

Log in to vote
0
Answered by 6 years ago

Remove Line 26 and replace it with this. [MAKE SURE THE PART IS NOT ANCHORED!]

local move = Instance.new("BodyVelocity", part)
move.MaxForce = Vector3.new(math.huge,math.huge,math.huge)
move.Velocity = plr.Character.Torso.CFrame.lookVector*100

Brief explaination; We will create an object called BodyVelocity. Then we will change the MaxForce (or max power) and changing the Velocity to face the character's direction, defined as plr.Character.Torso.CFrame.lookVector . lookVector is the property of CFrame, AND NO OTHER ELSE!! lookVector just means where an object is looking or where the surface called FrontSurface of a part is facing. You can change the 100 to something else since it tells how fast it is going, and 100 is kinda fast. Hope this helps!

0
It does not work for me. LuaDLL 253 — 6y
0
Oh now I see the reason reading it one more time. You need to make sure the part is NOT anchored and CanCollide must be true. Sorry for the late response, I have been. CounterBoy123 53 — 6y
Ad

Answer this question