Scripting HelpersARCHIVE
A little piece of Roblox history. Preserved for everyone, one question at a time.Read about the archive →
✓ ANSWER ACCEPTED

How to position a part?

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

✓ Accepted answer

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

2 comments

1

Thanks for the answer! It works, and there are no glitches. Thanks again!

0

Lol no problem. Glad to help! :)

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!

2 comments

0

Sadly, It doesn't work D: It just positions it to the center of the BasePlate, AKA Workspace.

0

Sorry about that. Just realized that you need to use CFrame. Position can only be used for non collision tps.

This discussion is preserved as it was. New answers, comments, and votes are closed.