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

How to add to a position when using instance.new?

Asked by 4 years ago
Edited 4 years ago

I'm trying to make a function which when a player joins it creates a new part in a different position, I want them to separate by adding to the position. Here is the code I used:

`game.Players.PlayerAdded:Connect(function(newbuildingspot)

1local NewBuildingSpot = Instance.new("Part")
2NewBuildingSpot.Parent = game.BuildingSpotFolder
3NewBuildingSpot.Size(3,5,50)
4NewBuildingSpot.BrickColor = BrickColor.new("Beige")
5NewBuildingSpot.Position(+0,+12,+15) `

end) Mainly concerned on the last one and wanted I hope that someone with more experience can point out my error/s.

0
i think you should do NewBuildingSpot.Position = whateverthingitis.Position + Vector3.new(0,12,15) iMazariuz 36 — 4y
0
Also i'm not sure wether you should be using .Position or .CFrame. Because last time i tried using .Position it kinda resulted in an undefined behavior lol iMazariuz 36 — 4y
0
Thank you for your reply, didn't seem to work for me when I used both .Position and .CFrame., I did end up finding the solution on the DevForums after trying .Position. nafey200 59 — 4y

1 answer

Log in to vote
0
Answered by
Xapelize 2658 Moderation Voter Community Moderator
4 years ago
Edited 4 years ago

You should use a Local Script, which only affect on player's client (only himself, like the Minecraft ender chest)

1game.Players.PlayerAdded:Connect(function(player)
2    local NewBuildingSpot = Instance.new("Part", player.CurrentCamera)
3    NewBuildingSpot.Parent = game.BuildingSpotFolder
4    NewBuildingSpot.Size(3,5,50)
5    NewBuildingSpot.BrickColor = BrickColor.new("Beige")
6    NewBuildingSpot.Position(math.Random(0,12), math.Random(0,15)) -- Randomize the Building Spot's Position
7end)
Ad

Answer this question