Same thing like i said. (scroll up or see)
Hmm… It did the same thing, worse, the ground too.
Edit: This is a very challenging task. Thanks for helping me. Try doing if statements?
Same thing like i said. (scroll up or see)
Hmm… It did the same thing, worse, the ground too.
Edit: This is a very challenging task. Thanks for helping me. Try doing if statements?
Yeah, it’s hard. It’s more of a trial and error mathematical thing.
This might do something:
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 getVectorThingy(normal)
local largestVector, vectorValue = "X", 0
for name, value in pairs({X = normal.X, Y = normal.Y, Z = normal.Z}) do
if vectorValue < value then
largestVector, vectorValue = name, value
end
end
return largestVector
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()[getVectorThingy(normal)]) -- using this function because vector math doesn't work like that
)
end
end
-- update every frame
game:GetService("RunService").RenderStepped:connect(placeAtMouse)
It kind of is. Also, you kinda made an error at this line:
largestVector, vectorValue = name
Fixed!
30 characters
Line 50. This is kinda funny. Well, pure pressure I guess.
What’s on line 50? I can’t tell.
CFrame.new(mouse.Hit.p + (moveModel:GetExtentsSize()[getVectorThingy(normal)])) – using this function because vector math doesn’t work like that
nevermind fixed again!
aaaaa
I feel bad for you currently, but heres the error:
22:02:54.560 - Players.Enchanted_Tix.Backpack.BuildingTool.ToolScript:50: bad argument #2 to '?' (Vector3 expected, got number)
AAAAAAAAAAAAAAAA
Should finally be fixed…
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 getVectorThingy(normal)
local largestVector, vectorValue = "X", 0
for name, value in pairs({X = normal.X, Y = normal.Y, Z = normal.Z}) do
if vectorValue < value then
largestVector, vectorValue = name, value
end
end
return largestVector
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 + (normal * moveModel:GetExtentsSize())) -- using this function because vector math doesn't work like that
)
end
end
-- update every frame
game:GetService("RunService").RenderStepped:connect(placeAtMouse)
I know how much pain you’re going through. Lets do this tomorrow. (it was an oof like last time)
It’s not that bad, but I’m honestly just determined to do this.
Alright. Give it all you got! (Nah actually take some rest first then do it)
Doing it again, here you go.
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 getVectorThingy(normal)
local largestVector, vectorValue = "X", 0
for name, value in pairs({X = normal.X, Y = normal.Y, Z = normal.Z}) do
if vectorValue < value then
largestVector, vectorValue = name, value
end
end
return largestVector
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 + (normal * moveModel:GetExtentsSize())) -- using this function because vector math doesn't work like that
)
end
end
-- update every frame
game:GetService("RunService").RenderStepped:connect(placeAtMouse)
Ahh… Still the same. Oof. I honestly give up.
Moby this is going to be a good idea, but try using velocity’s because it is more easier.
Velocity won’t work like that unfortunately.
Oh… try… adding more values? For example, CFrame.new(0,0+2,0)
What I need to do, is I need to figure out how to add the axis of which the surface is touching.
So basically, if it’s on top, you add the size of of the Y.
@Enchanted_Tix Mind showing me what is happening?