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

Firing a Projectile from a Tool. Nil value?

Asked by 4 years ago

Hello! Thank you for clicking on my post. I have been having this problem with this script, and after doing it when I click. The output says, "Players.MasterGamerHD7.Backpack.M I L K.LocalScript:20: attempt to index nil with 'Torso'" Here is the code...

local player = game.Players.LocalPlayer
local char = player.Character


function GetMilk()
    local milk = game.Workspace.Milk
    local m = Instance.new("SpecialMesh", game.Workspace.Milk)
    m.MeshId = "rbxassetid://489308589"
    m.TextureId = "rbxassetid://489308634"
    Instance.new("BodyVelocity", milk)
    return milk
end


script.Parent.Equipped:Connect(function(mouse)
    mouse.Button1Down:Connect(function()
        local mH = mouse.Hit
        local Milk1 = GetMilk()
        game.Workspace.Milk.Transparency = 0
        Milk1.CFrame = script.Parent.Handle.CFrame * CFrame.new(char.Torso.CFrame.lookVector * 3)
        Milk1.CFrame = CFrame.new(Milk1.Position, mH.milk)
        Milk1.BodyVelocity.velocity = Milk1.CFrame.LookVector * 120
    end)
end)

PS: I'm trying to make a throw able milk tool...

0
Is the game R6 or R15? NotedAPI 810 — 4y
0
I'm assuming that the characters in this game are R15, so use UpperTorso intead of Torso sheepposu 561 — 4y
0
It's R6 WyattDevv 29 — 4y

Answer this question