Hey! So I am trying to make a tool where when you have it equipped it will spawn a part where you click, I am wanting to do this but the code I have made below will not work?
NVM, I see the issue. The problem is in networking.
Try creating a LocalScript with the same code. The problem is that mouse can only be checked on the client’s side. You’ll have to make the LocalScript handle input (click position) and a separate normal Script for the parts. Also, use remote events to communicate.
Hey there! This code is mostly right except for a couple things, you’re doing Mouse.Target which does not give a CFrame but instead whatever the mouse is hovering over, and what I’m presuming by local Mouse = script.Parent.Parent.Parent:GetMouse() is that this is not in a local script, in order to use mouse you need to have it in a local script, so put this in a local script and the following code.
local Mouse = game:GetService("Players").LocalPlayer:GetMouse()
script.Parent.Activated:Connect(function() -- no need to do equipped since you can do Tool.Activated
local Part = Instance.new("Part")
Part.Parent = workspace
Part.Shape = "Ball"
Part.Size = Vector3.new(0.5, 0.5, 0.5) -- use .new to set the size.
Part.Material = Enum.Material.Neon -- it is reccommended to use Enums instead of just stating the material, not sure why.
Part.Color = Color3.fromRGB(255,255,255)
Part.Name = "WeldPart"
Part.CFrame = Mouse.Hit -- mouse.hit is the mouses CFrame
end)
-- note that this will only be on the clients side, in order to replicate it you'd need to use events