local tool = script.Parent local player = game.Players.LocalPlayer local house = game.Lighting.House target = game.Players.LocalPlayer:GetMouse().Target script.Parent.MouseButton1Click:Connect(function() wait(target) local part = house:Clone() part.Parent = workspace part:SetPrimaryPartCFrame(Vector3.new(target)) end)
I have problem that been more than 2 months with trying and i didn't know how to fix it, i want the house copy at mouse position, I click the button then i click again and the house copy itself at second click position but Setprimarypartcframe isn't working, please help i am starting to get annoying for it.
First thing - you might want to name your variables something clearer - the part variable is a model right? Why not name it houseModel or something?
Anyway - the issue is that part:SetPrimaryPartCFrame() is expecting a CFrame, but you are passing a Vector3. This is a simple fix, just wrap your Vector3 in a CFrame contstructor:
local tool = script.Parent local player = game.Players.LocalPlayer local house = game.Lighting.House target = game.Players.LocalPlayer:GetMouse().Target script.Parent.MouseButton1Click:Connect(function() wait(target) local part = house:Clone() part.Parent = workspace part:SetPrimaryPartCFrame(CFrame.new(Vector3.new(target))) end)
Hope this helps, happy coding :)
There are 2 problems causing this error: You are creating a new Vector3 using an object as a parameter You are setting the CFrame of a part to a Vector3
The first problem is very easy to fix: Simply access the .Position property of target, and forget the entire Vector3.new() part, this'll give you the Vector3 you want.
The second problem is actually also quite easy to fix: If you want to set the CFrame of something to a new CFrame, you can do so by using CFrame.new(...) This'll accept 1-2 parameters, the first is the position, the second is what the CFrame points towards. In this case, use target.Position as the first parameter, and use that for :SetPrimaryPartCFrame()
Implementing these 2 changes, your code will look like this:
local tool = script.Parent local player = game.Players.LocalPlayer local house = game.Lighting.House target = game.Players.LocalPlayer:GetMouse().Target script.Parent.MouseButton1Click:Connect(function() wait(target) local part = house:Clone() part.Parent = workspace part:SetPrimaryPartCFrame(CFrame.new(target.Position)) end)