wait moby,
heres a vid of what i have saw:
Did you use the code provided?
Yes. I copied and pasted it. :\
But I added target filter. did that do something wrong?
No, you didn’t the function only places on the surface. I’m thinking of a way of doing this.
Pay attention to what details I added and correct them:
local player = game.Players.LocalPlayer
local partFolder = Instance.new("Folder") -- folders are better
partFolder.Name = "ModelParts"
partFolder.Parent = workspace
local playerBuild = Instance.new("Folder")
playerBuild.Parent = workspace
playerBuild.Name = player.Name .. " Space"
local moveModel = Instance.new("Model")
moveModel.Parent = partFolder
local part = Instance.new("Part") -- turned into a model just for you, it works significantly better
part.Parent = moveModel
part.Size = Vector3.new(3, 3, 3)
part.Name = player.Name .. " Part"
part.Anchored = true
moveModel.PrimaryPart = part
local mouse = player:GetMouse()
mouse.TargetFilter = part;
function placeAtMouse(dt) -- egomoose's solution
if (mouse.Target) then
-- where we cast our ray from (shifted slightly up so the ray will hit the surface we're hovering)
local origin = mouse.Hit.p + Vector3.new(0, 0.1, 0)
-- cast our ray and get our normal, which is a unit vector
local ray = Ray.new(origin, Vector3.new(0, -1, 0))
local hit, pos, normal = workspace:FindPartOnRay(ray, moveModel)
-- get the perpendicular vector and the angle between the two
local cross = Vector3.new(0, 1, 0):Cross(normal)
local theta = math.acos(Vector3.new(0, 1, 0):Dot(normal))
-- make sure our axis is valid
local axis = Vector3.new(1, 0, 0)
if (cross.magnitude > 0) then
axis = cross.unit
end
-- CFrame the model
moveModel:SetPrimaryPartCFrame(
CFrame.new(mouse.Hit.p + normal * moveModel:GetModelSize().y/2) -- position
* CFrame.fromAxisAngle(axis, theta) -- rotation
)
end
end
-- update every frame
game:GetService("RunService").RenderStepped:connect(placeAtMouse)
This should work quite a bit better, instead I went with NormalIds.
local player = game.Players.LocalPlayer
local partFolder = Instance.new("Folder") -- folders are better
partFolder.Name = "ModelParts"
partFolder.Parent = workspace
local playerBuild = Instance.new("Folder")
playerBuild.Parent = workspace
playerBuild.Name = player.Name .. " Space"
local moveModel = Instance.new("Model")
moveModel.Parent = partFolder
local part = Instance.new("Part") -- turned into a model just for you, it works significantly better
part.Parent = moveModel
part.Size = Vector3.new(3, 3, 3)
part.Name = player.Name .. " Part"
part.Anchored = true
moveModel.PrimaryPart = part
local mouse = player:GetMouse()
mouse.TargetFilter = moveModel
-- using this function because if i do 0 * n it will turn the vector to 0 allowing me to eliminate the vectors that don't multiply based on the surfaceid and then the ones that equal one will work.
function vectorMultiply(v1, v2)
return Vector3.new(v1.X * v2.X, v1.Y * v2.Y, v1.Z * v2.Z)
end
function placeAtMouse(dt) -- egomoose's solution
if (mouse.Target) then
-- where we cast our ray from (shifted slightly up so the ray will hit the surface we're hovering)
-- cast our ray and get our normal, which is a unit vector
local ray = Ray.new(mouse.Origin.p, mouse.Hit.p)
local hit, pos, normal = workspace:FindPartOnRay(ray, moveModel)
-- CFrame the model
moveModel:SetPrimaryPartCFrame(
CFrame.new(mouse.Hit.p + (vectorMultiply(moveModel:GetBoundingBox(), normal)) -- using this function because vector math doesn't work like that
)
end
end
-- update every frame
game:GetService("RunService").RenderStepped:connect(placeAtMouse)
Can I add target filter?
mouse.TargetFilter = part;
wait Never mind. Oof. I am not well.
Yes. You should. That’s how the IgnoreList works.
Edit: It’s already there.
Hmm… It did the same thing, worse, the ground too.
Edit:
I have an idea. Change the Vector3.new()'s and CFrame.new()'s and (ect)()
Nope, try the new one. I just edited it again.
The one you just posted? Or the one that is coming out soon?
The one I just posted, I edited it.
I tried. Still, the same. Hmmm…
For testing purposes, I’m just going to add the size of the model.
local player = game.Players.LocalPlayer
local partFolder = Instance.new("Folder") -- folders are better
partFolder.Name = "ModelParts"
partFolder.Parent = workspace
local playerBuild = Instance.new("Folder")
playerBuild.Parent = workspace
playerBuild.Name = player.Name .. " Space"
local moveModel = Instance.new("Model")
moveModel.Parent = partFolder
local part = Instance.new("Part") -- turned into a model just for you, it works significantly better
part.Parent = moveModel
part.Size = Vector3.new(3, 3, 3)
part.Name = player.Name .. " Part"
part.Anchored = true
moveModel.PrimaryPart = part
local mouse = player:GetMouse()
mouse.TargetFilter = moveModel
-- using this function because if i do 0 * n it will turn the vector to 0 allowing me to eliminate the vectors that don't multiply based on the surfaceid and then the ones that equal one will work.
function vectorMultiply(v1, v2)
return Vector3.new(v1.X * v2.X, v1.Y * v2.Y, v1.Z * v2.Z)
end
function placeAtMouse(dt) -- egomoose's solution
if (mouse.Target) then
-- where we cast our ray from (shifted slightly up so the ray will hit the surface we're hovering)
-- cast our ray and get our normal, which is a unit vector
local ray = Ray.new(mouse.Origin.p, mouse.Hit.p)
local hit, pos, normal = workspace:FindPartOnRay(ray, moveModel)
-- CFrame the model
moveModel:SetPrimaryPartCFrame(
CFrame.new(mouse.Hit.p + moveModel:GetBoundingBox()) -- using this function because vector math doesn't work like that
)
end
end
-- update every frame
game:GetService("RunService").RenderStepped:connect(placeAtMouse)
Bounding box function broke it.
local player = game.Players.LocalPlayer
local partFolder = Instance.new("Folder") -- folders are better
partFolder.Name = "ModelParts"
partFolder.Parent = workspace
local playerBuild = Instance.new("Folder")
playerBuild.Parent = workspace
playerBuild.Name = player.Name .. " Space"
local moveModel = Instance.new("Model")
moveModel.Parent = partFolder
local part = Instance.new("Part") -- turned into a model just for you, it works significantly better
part.Parent = moveModel
part.Size = Vector3.new(3, 3, 3)
part.Name = player.Name .. " Part"
part.Anchored = true
moveModel.PrimaryPart = part
local mouse = player:GetMouse()
mouse.TargetFilter = moveModel
-- using this function because if i do 0 * n it will turn the vector to 0 allowing me to eliminate the vectors that don't multiply based on the surfaceid and then the ones that equal one will work.
function vectorMultiply(v1, v2)
return Vector3.new(v1.X * v2.X, v1.Y * v2.Y, v1.Z * v2.Z)
end
function placeAtMouse(dt) -- egomoose's solution
if (mouse.Target) then
-- where we cast our ray from (shifted slightly up so the ray will hit the surface we're hovering)
-- cast our ray and get our normal, which is a unit vector
local ray = Ray.new(mouse.Origin.p, mouse.Hit.p)
local hit, pos, normal = workspace:FindPartOnRay(ray, moveModel)
-- CFrame the model
moveModel:SetPrimaryPartCFrame(
CFrame.new(mouse.Hit.p + moveModel:GetExtentsSize()) -- using this function because vector math doesn't work like that
)
end
end
-- update every frame
game:GetService("RunService").RenderStepped:connect(placeAtMouse)
Some good news and some bad news:
That’s good, working as expected. Now you should be able to do this.
local player = game.Players.LocalPlayer
local partFolder = Instance.new("Folder") -- folders are better
partFolder.Name = "ModelParts"
partFolder.Parent = workspace
local playerBuild = Instance.new("Folder")
playerBuild.Parent = workspace
playerBuild.Name = player.Name .. " Space"
local moveModel = Instance.new("Model")
moveModel.Parent = partFolder
local part = Instance.new("Part") -- turned into a model just for you, it works significantly better
part.Parent = moveModel
part.Size = Vector3.new(3, 3, 3)
part.Name = player.Name .. " Part"
part.Anchored = true
moveModel.PrimaryPart = part
local mouse = player:GetMouse()
mouse.TargetFilter = moveModel
-- using this function because if i do 0 * n it will turn the vector to 0 allowing me to eliminate the vectors that don't multiply based on the surfaceid and then the ones that equal one will work.
function vectorMultiply(v1, v2)
return Vector3.new(v1.X * v2.X, v1.Y * v2.Y, v1.Z * v2.Z)
end
function placeAtMouse(dt) -- egomoose's solution
if (mouse.Target) then
-- where we cast our ray from (shifted slightly up so the ray will hit the surface we're hovering)
-- cast our ray and get our normal, which is a unit vector
local ray = Ray.new(mouse.Origin.p, mouse.Hit.p)
local hit, pos, normal = workspace:FindPartOnRay(ray, moveModel)
-- CFrame the model
moveModel:SetPrimaryPartCFrame(
CFrame.new(mouse.Hit.p + (moveModel:GetExtentsSize() * normal)) -- using this function because vector math doesn't work like that
)
end
end
-- update every frame
game:GetService("RunService").RenderStepped:connect(placeAtMouse)