Ad
Log in to vote
2

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

Asked by 5 days ago
Edited 5 days 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)

local NewBuildingSpot = Instance.new("Part")
NewBuildingSpot.Parent = game.BuildingSpotFolder
NewBuildingSpot.Size(3,5,50)
NewBuildingSpot.BrickColor = BrickColor.new("Beige")
NewBuildingSpot.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) LoyalQuickAngel 7 — 5d
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 LoyalQuickAngel 7 — 5d
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 10 — 5d

1 answer

Log in to vote
0
Answered by
Xapelize 858 Moderation Voter
5 days ago
Edited 5 days ago

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

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

Answer this question