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

How to position a part?

Asked by
KordGamer 155
9 years ago

I know how to do this, But it just isn't working. Everything else in this code works. I want to position the new part to the person that died's torso.

Any help would be appreciated!

Here is the code:

--Created by KordGamer
game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function(Died)
          for i =1,script.GoldCount.Value do

        local xp = Instance.new("Part")

        xp.Parent = game.Workspace

        xp.Position = Vector3.new(character.Torso.Position + Vector3.new(math.random(-3,3),math.random(-3,3),math.random(-3,3)))

        xp.Shape = 0

        xp.formFactor = "Symmetric"

        xp.Name = "XP"

        xp.BrickColor = BrickColor.new(24)

        xp.Reflectance = 0.5

        xp.Size = Vector3.new(1,1,1)

        local clone = script.Increase:Clone()

        clone.Disabled = false

        clone.Parent = xp

    end
end)

    end)
end)

--Created by KordGamer

As I said, Everything else works apart from the position part. It just positions it to the center of the BasePlate, AKA Workspace.

2 answers

Log in to vote
1
Answered by 9 years ago

I tested the script and It seems to work. So here:

game:GetService('Players').PlayerAdded:connect(function(player)
    player.CharacterAdded:connect(function(character)
        character:WaitForChild("Humanoid").Died:connect(function(Died)
print(character.Name)
local Part  = Instance.new("Part" , game.Workspace)-- This create the Part and puts the Part inside of Workspace
Part.Anchored = true--This is to make sure the part doesn't fall into the void and gets deleted.
Part.CFrame = character.Torso.CFrame--This CFrame the Parts position to the Torso's Location.
        end)
    end)
end)

If you don't understand the something that I wrote feel free to ask me :) If you want more information about CFrame then please go to this or ask me!: CFrame

1
Thanks for the answer! It works, and there are no glitches. Thanks again! KordGamer 155 — 9y
0
Lol no problem. Glad to help! :) UserOnly20Characters 890 — 9y
Ad
Log in to vote
0
Answered by 9 years ago

Simple answer:

 xp.CFrame = Vector3.new(character.Torso.Position) + Vector3.new(math.random(-3,3),math.random(-3,3),math.random(-3,3))

It should work, but if it doesn't contact me!

0
Sadly, It doesn't work D: It just positions it to the center of the BasePlate, AKA Workspace. KordGamer 155 — 9y
0
Sorry about that. Just realized that you need to use CFrame. Position can only be used for non collision tps. TheDeadlyPanther 2460 — 9y

Answer this question