✓ Accepted answer
Why did you define a mouse if you weren't going to use it in the first place? lol
First issue is that the Mouse argument is a newly created Mouse object that isn't the player's mouse. It exists, so it won't error, but the functions won't run.
Your second issue is that Mouse.Hit is a CFrame value, but it won't return the CFrame's Vector value.
Here's your code:
local mouse = game.Players.LocalPlayer:GetMouse()
local Tool = script.Parent
local location = mouse.Hit
Tool.Equipped:connect(function(Mouse)
Mouse.Button1Down:connect(function()
local part = Instance.new('Part')
part.Parent = workspace
part.Anchored = true
part.CFrame = location
end)
Mouse.Button1Up:connect(function()
wait(30)
game.Workspace.Part:remove()
end)
end)
Here's your code, but with some fixes:
local mouse = game.Players.LocalPlayer:GetMouse()
local Tool = script.Parent
Tool.Equipped:connect(function()
mouse.Button1Down:connect(function()
local location = mouse.Hit.p
local part = Instance.new('Part')
part.Parent = workspace
part.Anchored = true
part.Position = location
end)
mouse.Button1Up:connect(function()
wait(30)
game.Workspace.Part:remove()
end)
end)
If this helped you, don't forget to accept the answer :D
2 comments
@DepressionSensei Players.Player1.Backpack.Place.LocalScript:11: bad argument #3 to 'Position' (Vector3 expected, got CFrame)
Sorry, set location to mouse.Hit.P, I accidentally added that to the wrong code block