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

Mouse is not a valid member of Vector3?

Asked by 3 years ago

Very confused on why I'm getting this error, I'm trying to make a tool make a part from replicatedstorage clone to workspace when clicked on with it activated and then its cframe will be constantly moving forward in the spot your mouse clicks on, but for some reason I keep getting that error. Heres the script:

local Tool = script.Parent
local Cooldown = false
local CDTime = 65



Tool.RemoteEvent.OnServerEvent:Connect(function(Player, Mouse)
    if Cooldown then return end 

    spawn(function()
        Cooldown = true 
        wait(CDTime)
        Cooldown = false 
    end)

    local Mugetsu = game.ReplicatedStorage.Abilities.Shinigami.Parts.Mugetsu:Clone()
    Mugetsu.Size = Vector3.new(1.427, 44.539, 1.55)
    Mugetsu.Parent = game.Workspace
    local pos = Player.Character.Head.Position + CFrame.new(Player.Character.Head.Position,Mouse.p).lookVector * 1 
    Mugetsu.CFrame = CFrame.new(pos.Mouse.p)
    Mugetsu.CanCollide = false
    Mugetsu.Anchored = false
    Mugetsu:SetNetworkOwner(Player)
    local BodyVelocity = Instance.new("BodyVelocity",Mugetsu)
    BodyVelocity.Velocity = Mouse.lookVector * 200
    BodyVelocity.MaxForce = Vector3.new(1e8,1e8,1e8)
    game.Debris:AddItem(Mugetsu,3.5)

    Mugetsu.Touched:Connect(function(hit)
        if hit and not hit.Parent:FindFirstChild("Humanoid") and hit.CanCollide == true then 
            Mugetsu:Destroy()
        end
    end)

    Mugetsu.Touched:Connect(function(hit)
        if hit.Parent == Player.Character then return end
        if hit and hit.Parent:FindFirstChild("Humanoid") then 
            local EnemyHum = hit.Parent:FindFirstChild("Humanoid")
            EnemyHum:TakeDamage(100)
            Mugetsu:Destroy()

        end
    end)
end)    


Please help

0
On line 19 you set "pos" to a Vector3 Value. And on line 20 you do "pos.Mouse". Mouse is not a property or something of a Vector3 Value. I honestly don't see what's so confusing Spjureeedd 385 — 3y
0
Okay Sabertooth11123 38 — 3y

1 answer

Log in to vote
1
Answered by 3 years ago

Mouse doesnt have a Vector3. Mouse Probably uses CFrame. For a reminder, Vector3 is the code snippet that can edit positions of this in 3d space, not 2d. Plus, You should use a localscript because only the client can access its own mouse. Sorry if it sounded rude ;-;

0
I got it fixed, and its alright Sabertooth11123 38 — 3y
Ad

Answer this question