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

Invalid argument #2 (Vector3 expected, got nil)?

Asked by 2 years ago

local

function BIGBlaster()
    if activu == true then return end
    if bigblastercooldown == true then return end
    activu = true
    bigblastercooldown = true
    punchsfx:Play()
    local mousehit = mouse.Hit.p
    bigblastevent:FireServer(mousehit)
    wait(0.4)
    activu = false
    wait(25)
    local bigblastercooldown = false
end

(mouse is defined further up in the script)

server

game:GetService("ReplicatedStorage").DTWAUBlast.OnServerEvent:Connect(function(player, mousehit)
    local chr = player.Character
    local rarm = chr["Right Arm"]
        local hed = chr["Head"]


    local blaster = game.ServerStorage.DTWAUActualBlast
    local gblaster = blaster:Clone()
    gblaster.Parent = workspace.Effects

        gblaster.CFrame = CFrame.new(chr.HumanoidRootPart.Position, mousehit) * CFrame.Angles(math.pi/2, 0, 0)

its meant to be a gun that shows up behind you and aims towards the mouse.

it keeps giving me Invalid argument #2 (Vector3 expected, got nil), what exactly am i missing or doing wrong here?

0
Which line does the error come from? SimpleFlame 255 — 2y
0
You should never use wait(n) or wait() it can be really bad for your game's performance. MarkedTomato 810 — 2y
0
what is mousehit? MarkedTomato 810 — 2y
0
comes from line 11 in server, mousehit is mouse.Hit.p hgfdswer22 5 — 2y
View all comments (3 more)
0
why do you have 2 vector3's inside of the CFrame? CFrame takes in 3 axis which are x, y and z. which makes it a vector3 MarkedTomato 810 — 2y
0
So what do i do with mousepos then? hgfdswer22 5 — 2y
0
Hi, I believe the problem for you here is: You need to define a 3rd value. Vector3 = (X,Y,Z) Your X was defined as chr.HumanoidRootPart.Position Your Y was defined as mousehit Your Z must be defined. Other than this, I don't know how else to help you. 2Loos 168 — 2y

Answer this question