Why won't the following code work? Mouse.hit
This code is in a Local Script in a tool. It should create parts at the location of the mouse with the Object Hearts as a child of it. It creates the part with the child, but it spawns at 0,0,0. Any ideas?
01 | local tool = script.Parent |
02 | local player = game.Players.LocalPlayer |
03 | local mouse = player:GetMouse() |
05 | local function onActivate() |
06 | local character = tool.Parent |
07 | local hit = mouse.Hit.p |
08 | local part = Instance.new( "Part" , character) |
09 | local hearts = tool.Hearts:Clone() |
11 | part.Size = Vector 3. new( 1 , 1 , 1 ) |
12 | part.CanCollide = false |
13 | part.Position = Vector 3. new(hit) |
17 | tool.Activated:connect(onActivate) |