Help with my math question

I’m ultra noob at roblox studio so my script is very different from other expert scripters.
So help me with this,pleaseeee.
It’s quite hard I can’t figure out how to solve the problem out.

The first one is quite normal right?
But check this out…


It doesn’t look quite right on slope.
What can I do know?
I can’t figure out how to calculate the orientation of the black part.

Just help me with it…

Edit:
My problem:


My goal:

I hope u guys know what I mean…

-------------- Explorer --------------
Explorer

Script(Worker)

script.Parent.Equipped:Connect(function(Mouse)
local Humanoid = script.Parent.Parent:FindFirstChild(“Humanoid”)
script.Parent.Head.CanCollide = false
local Hold = script.Parent.Parent.Humanoid:LoadAnimation(script.Hold)
local Start = script.Parent.Parent.Humanoid:LoadAnimation(script.Start)
local Dig = script.Parent.Parent.Humanoid:LoadAnimation(script.Dig)
Hold:Play()
script.Parent.Activated:Connect(function()
if Mouse ~= nil then
local Target = Mouse.Target
local Hit = Mouse.Hit
if (Hit.p - script.Parent.Parent.HumanoidRootPart.Position).Magnitude < 5 then
Hold:Stop()
Humanoid.WalkSpeed = 0
Humanoid.JumpPower = 0
Start:Play()
wait(0.5)
Dig:Play()
wait(1)
local Event1 = script.Parent.PartCreator.CreateHole
local Event2 = script.Parent.PartCreator.Product
Event1:FireServer(Hit,script.Parent.Head.Orientation,script.Parent.Head.Size,Target)
Event2:FireServer(Hit,script.Parent.Head.Orientation,script.Parent.Head.Size,Target.DirtColor.Value,Target.CustomPhysicalProperties)
end
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
Hold:Play()
end
end)
script.Parent.Unequipped:Connect(function()
script.Parent.Head.CanCollide = true
Hold:Stop()
Start:Stop()
Dig:Stop()
Humanoid.WalkSpeed = 16
Humanoid.JumpPower = 50
end)
end)

Script(PartCreator)

script.CreateHole.OnServerEvent:Connect(function(plr,Hit,Orientation,Size,target)
local Part = Instance.new(“Part”)
Part.TopSurface = Enum.SurfaceType.Smooth
Part.BottomSurface = Enum.SurfaceType.Smooth
Part.CFrame = Hit
Part.Orientation = Vector3.new(0,Orientation.Y,0) <---- where the problem at.
Part.BrickColor = BrickColor.Black()
Part.Anchored = true
Part.CanCollide = false
Part.Size = Size
Part.Parent = game.Workspace
wait(60*10)
Part:Destroy()
end)
script.Product.OnServerEvent:Connect(function(plr,Hit,Orientation,Size,Color,Properties)
local Part = Instance.new(“WedgePart”)
local Ownership = Instance.new(“StringValue”)
Ownership.Value = plr.Name
Part.Material = Enum.Material.Concrete
Part.CFrame = Hit
Part.BrickColor = Color
Part.Anchored = false
Part.Size = Vector3.new(Size.Z,math.random(20,25)/10,Size.X)
Part.Parent = game.Workspace
Part.CustomPhysicalProperties = Properties
local Number = math.random(1,2)
local Sound = script:FindFirstChild(“Sound”…Number)
Sound:Play()
end)


if you don’t know I mean, just ignore all the things I wrote above.

Now is the another example:

First, we start off a part with Orientation:Vector3.new(-30,0,0)

Second, we add another part which is red with Orientation:Vector3.new(-30,0,0)

Last step, Rotate the red part 30 degrees.

Then we can know its Orientation:Vector3.new(-25.66, 33.69, -16.1)

So my question is, how can I calculate the orientation of red part with only these things:

1,The orientation of the grey part.

2,30 degrees(That I rotated the red part)

Gimme the formula if you know how :grinning:

Here is my shovel and a ground that works with the shovel:

Demo.rbxm (19.7 KB)

Note: The Shovel only works with the given land.

1 Like

I can’t find your problem, as i see the last part you wrote, you accidentally deleted the next part or did you just forgot to write it? I would like to help you

EDIT: Oh nevermind you added it back, i can’t understand correctly your question but i think you are saying that you cant calculate the orientation of your block with the script right?
you can add this script:

while wait(1) do --Every 1 seconds the script finds the orientation
local Orientation = script.Parent.Orientation --The script is inside the block

Im new at scripting too, i hope this can help you

1 Like

yes,um…
I accidentally post it when I was writing it.

you can weld the things together using weld constraint and they will stay in place no matter what(unless you break the weld)

I need to make the black part like glue to the slope instead of sinking into the slope.

By the way, the part was created by the script of the tool.(Using Instance.new(“Part”))
So I can’t insert a script into the black part.

The point is I need to place it in the correct orientation.

yes, I know that. Just try to weld it when it touches each other with a bit of delay so the brick goes on fully
you can use

script.Parent.Touched:Connect(function(part)
if part.Name == 'partname' then
weld = Instance.new("WeldContraint")
weld.Parent = script.Parent
wait(0.1)
weld.Part1 = script.Parent
weld.Part2 = part
part.Orientation = the tools orientation
end
end)

can you show us a video of the problem?

That doesn’t look like it can change its orientation

I changed it, hope it works out. Oh, you changed it, the first one looks just fine to me

Add this when you create the instance, like when you use a local script in the tool :

local tool = script.Parent, not tested
    --or whatever you want
    local debounce = false

    tool.Activated:Connect(function()
          if not debounce then
        debounce = true
        wait(0.3)
       local part = Instance.new("Part")
             part.Anchored = true 
            part.Orientation = Vector3.new (0,0,0)
            part.Position=Vector3.new(1197.153, 67.391, -200.311)--postion
           part.Name = "MyPart"
         wait(1)
         debounce = false
          end	
      end)

Woah

It looks kinda difficult(For me)

It’s nothing difficult to be honest, it’s not as complex as table, datastores etc. (comparatively, but I don’t find them hard, nobody should if they’ve spent time learning) so it should be pretty simple
all I did was change the part’s orientation

local part = workspace.part
part.Orientation=0,0,0

Ask if you didn’t understand something.

1 Like

also teach me what debounce is.

I just showed debounce as an example, but if you’ve already scripted your tool then you just had to add one line there

“it keeps a function from running too many times, .” hence reducing memory consumption.
You can learn all about debounce by clicking right here .

oh maybe I already got it. I just donno what debounce is.(maybe)

like this ?

local CoolingDown = false
script.Parent.Touched:connect(function()
if CoolingDown = false then
CoolingDown = true
wait(5)
CoolingDown = false
end
end)

Doesn’t It means that It can prevent a script overreact, does it?

As you wrote:
local part = workspace.part part.Orientation=0,0,0

but there will be lots of things named “part”
that’s another problem

you can change your parts name or define a variable associated to it like :

    local part = workspace.WhateverYourPartNameIs
    local val = Vector3.new(0,0,0)
    part.Orientation=val

or you could directly parent a script to it , like :

local val = Vector3.new(0,0,0)

script.Parent.Orientation=val--meaning whatever the parent of the script you kept it in is, change it's orientation to our previously defined variable. 

Or you could simply do this when referencing to it like we did in our first script :

 local part = workspace.WhateverYourPartNameIs

        part.Orientation = Vector3.new(0,0,0)
1 Like

you defined the part as Mouse.Hit

but there will be lots of things named “part”
that’s another problem
also, the line about the orientation should be

Part.Orientation = Hit.Orientation
hit is the ground that is targeted and Part is the shovel