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

Positions and Vector3?

Asked by 10 years ago

Two errors with this script.

It doesn't change the position of the new parts. And. It doesn't add 1 to the logs cut value.

script.Parent.Touched:connect(function(hit)
        if hit.Name == "Log" then
            planks = hit.Planks.Value
        for i = 1, tonumber(planks) do
            part = Instance.new("Part", Workspace)
            part.BrickColor = hit.BrickColor
            part.FormFactor = "Custom"
            part.Size = Vector3.new(hit.Size.X/5 ,hit.Size.Y, hit.Size.Z/2)
            part.Rotation = Vector3.new(90, 90, 0)
            part.Position = Vector3.new(hit.Position)
            part.TopSurface = "Smooth"
            part.BottomSurface = "Smooth"           
            hit:Remove()
        end
        game.Workspace.LogsCut = game.Workspace.LogsCut + 1
    end
end)
0
Fixed 2nd error with a tonumber(--code) YellowoTide 1992 — 10y

1 answer

Log in to vote
2
Answered by
Discern 1007 Moderation Voter
10 years ago

I am assuming "Hit" is a Part.

Now, "Hit" has a Vector3 Value Position. Since you are copying that value from the part "Hit" is is not a new Vector3.

Just change Line 10 to this and it should function properly.

part.Position = hit.Position

Hope I helped. :)

0
Hmm thanks! I thought everything had vector3 by it if it was a position, size, etc. YellowoTide 1992 — 10y
0
Well it IS a Vector3, but you just aren't creating a new one, so Vector3.NEW <-- Point Point would be creating a new one. :) Discern 1007 — 10y
Ad

Answer this question