Scripting Helpers is winding down operations and is now read-only. More info→
Ad
Log in to vote
-1

how do I make a part become the same orientation as another part? [SERIOUS HELP NEEDED]

Asked by
zValerian 108
5 years ago

I have a script that where ever you click, a spell will fly there. If it hits a object with a humanoid, it will damage it and stun it. If it does not, then it will make a burn mark on where it is hit. My problem is that if a burn mark is made anywhere except the floor, it will stick out. For example, this is it on the floor:

https://gyazo.com/98ad24caa7f69301887ae4fa703ff9b9

But if I shoot it at a wall, this is how it will look:

https://gyazo.com/5a91e361458701f94115330e8ef670d5

Does anyone have any ideas how to make it rotate so it looks like it does on the floor? Here is the script. If you have any questions, comment them!

"a" is mouse.hit that I got from a local script

hit is the burn mark

game.ReplicatedStorage.stupefyy.OnServerEvent:Connect(function(player, name, a)

local animation = game.Players:FindFirstChild(name).Character.Humanoid:LoadAnimation(game.Workspace:FindFirstChild(name).Wand.Animation)
        animation:Play()
wait(.3)


--local ray = Ray.new(game.Workspace:FindFirstChild(name).Wand.Tip.Position(a - game.Workspace:FindFirstChild(name).Wand.Tip.Position).Unit * 750)

local character = game.Workspace:FindFirstChild(name)
local origin = character.Wand.Tip.Position
local ray = Ray.new(origin, (a - origin).Unit * 750)
local studsUporDown = 0.25
local timeTillNext = 0.025
local segmentLength = 2
local damageAmount = 10
local part = game.ReplicatedStorage.stup:Clone()
part.Parent = workspace
studsUporDown = studsUporDown * 100
local function entropy()
    local x = math.random(-studsUporDown,studsUporDown) / 50
    local y = math.random(-studsUporDown,studsUporDown) / 50
    local z = math.random(-studsUporDown,studsUporDown) / 50
  return Vector3.new(x, y, z)
end
spawn(function()
    for i = 0, 750, segmentLength do
        local Next = ray.Origin + i * ray.Direction.Unit + entropy()
    local damageRay = Ray.new(part.Position, (Next - part.Position).Unit * segmentLength)
part.CFrame = CFrame.new(Next)
    local hit, End = workspace:FindPartOnRay(damageRay, character, false, true)
if hit and hit ~= part then
        print(hit)
            local burn = game.ReplicatedStorage.hit

part:Destroy()
        part.CFrame = CFrame.new(End)
        local hum = hit.Parent:FindFirstChild("Humanoid") or hit.Parent.Parent:FindFirstChild("Humanoid")
        if hum then
            hum:TakeDamage(damageAmount)
            spawn(function()
                hum.PlatformStand = true
                wait(10)
                hum.PlatformStand = false
            end)
    else
    local burnHit = burn:Clone()
    burnHit.CFrame = CFrame.new(End)
    burnHit.Parent = workspace
        end
break
    end
        wait(timeTillNext)
    end
end)
end)

0
omg xD greatneil80 2647 — 5y
0
what zValerian 108 — 5y
0
I would use surface normals, they are one return value of FindPartOnRay https://www.robloxdev.com/api-reference/function/Workspace/FindPartOnRay Vulkarin 581 — 5y

1 answer

Log in to vote
-3
Answered by 5 years ago

How to make a part become the same orientation as another part?

local Part1 = game.Workspace.Part1
local Part2 = game.Workspace.Part2

Part2.Orientation = Part1.Orientation
0
read the thread... zValerian 108 — 5y
0
xd hellmatic 1523 — 5y
0
yes bhqpping 80 — 5y
Ad

Answer this question