im trying to remake a script i made where I could place parts into the map with a tool, for some reason im getting this error on line 35, any help?

--To do, fix this 
local tool = script.Parent
local player = game.Players.LocalPlayer
local character = player.Character
local handle = tool.Handle
local mouse = player:GetMouse()
local currentrotation = 0
local currentparttype = 0
local createdholopart = false

-- functions

local function holo(parttype)
	if not tool:FindFirstChild("HoloPart") then
	print("CreateHoloPart")
	if parttype == 0 then
		local holopart = tool.Assets.WallPartHologram:Clone()
		holopart.Name = "HoloPart"
		holopart.Parent = tool
	else
		if parttype == 1 then
			
		end
	end
	end
	
	
end

local function updholo(mouse)
	print("Updating")
	if tool:FindFirstChild("HoloPart") then
		print("Updated")
		local mouse = mouse
		tool.HoloPart.CFrame = CFrame.new(mouse.Hit.p) -- error is here
		tool.HoloPart.Rotation = Vector3.new(0, currentrotation, 0)
	end
end

-- events
tool.Equipped:Connect(function()
	holo(currentparttype)
	mouse.Idle:Connect(function(mouse)
--yeet	
		
--local function holo(parttype)
--	if parttype == 0 then
--		local holopart = tool.Assets.WallPartHologram:Clone()
--		holopart.Name = "HoloPart"
--	else
--		if parttype == 1 then
--			
--		end
--	end
--	
--	
--end
--
--local function updholo(mouse)
--	if tool:FindFirstChild("HoloPart") then
--		print("Updated")
--		local mouse = mouse
--		tool.HoloPart.CFrame = CFrame.new(mouse.Hit.p)
--		tool.HoloPart.Rotation = Vector3.new(0, currentrotation, 0)
--	end
--end	
		
--yeet
		print("Yo")
		if tool:FindFirstChild("HoloPart") then
			print("Sending updator")
			updholo(mouse)
		else
			holo(currentparttype)
		end	
	
	
	end)
	
	
	mouse.Button1Down:Connect(function(mouse)
		print("Clicked")
		print(mouse.Hit.p)
		
		
		
		
		
	end)

	game:GetService("UserInputService").InputBegan:Connect(function(input, gameProcessedEvent)
		if input.KeyCode == Enum.KeyCode.R then
			currentrotation = currentrotation + 45
		else
			if input.KeyCode == Enum.KeyCode.F then
				currentparttype = currentparttype + 1
				if tool:FindFirstChild("HoloPart") then
					tool.HoloPart:Destroy()
					holo(currentparttype)
				end	
				if currentparttype > 1 then
					currentparttype = 0
				end	
			end
		end
		
			
				
						
	end)
end)

8 comments

0

I think you should do hit.Position instead of Hit.p...idk

0

Really? its worked in literally every single other script i did

0

oh.........idk...I suck at scripting i thought you're talking about 3d object

0

Oh no, it gets the 3d position of the mouse via drawing a ray in the mouse direction and getting where it hits

0

Mouse.Hit actually return CFrame. So the 35 line should be: tool.HoloPart.CFrame = mouse.Hit https://developer.roblox.com/en-us/api-reference/property/Mouse/Hit

0

Pro tip: If you have any problems, search it up on DevForum, API sites, SH,... before asking.

0

Still getting that eror... @Block_manvn