Alright, let's recreate the situation. I have a LocalScript in my StarterPack and a normal Script in my ServerStorage. The LocalScript creates a brick at the mouse pointer when the mouse button is pressed and the Script is used to keep the part at it's position, but every time I walk by, it moves up.
01 | -- LocalScript in StarterPack |
02 | local player = game.Players.LocalPlayer |
03 | local mouse = player:GetMouse() |
04 | mouse.Button 1 Up:connect( function () |
05 | local Part = Instance.new( "Part" , Workspace) |
06 | Part.CanCollide = true |
07 | Part.Anchored = true |
08 | Part.Size = Vector 3. new( 1 , 10 , 10 ) |
09 | Part.Position = mouse.Hit.p) |
10 | local Script = game.ServerStorage.Script:Clone() |
11 | Script.Parent = Part |
12 | end ) |
1 | -- Script in ServerStorage |
2 | local Part = script.Parent |
3 | while wait() do |
4 | if Part.Position.y > 0 then |
5 | Part.Position = Vector 3. new(Part.Position.x, 0 , Part.Position.z) |
6 | end |
7 | end |
Does anyone know how I can make a Part stay at it's position, even though the player spawned it on top of his head?
Since you have "while wait() do" the part keeps moving?
I would just do this.
01 | --LocalScript in StarterGear or StarterGui. |
02 | local Player = game.Players.LocalPlayer |
03 | local Mouse = Player:GetMouse() |
04 |
05 | Mouse.Button 1 Down:connect( function () --Your call statement. |
06 | local Part = Instance.new( "Part" , game.Workspace) --Creates your brick and puts it into game.Workspace. |
07 | Part.Anchored = true |
08 | Part.CanCollide = true |
09 | Part.Transparency = 0 |
10 | Part.BrickColor = BrickColor.new( "Bright red" ) --Any color, Just lets you see your brick better. |
11 | Part.Size = Vector 3. new( 1 , 10 , 10 ) |
12 | Part.Position = Mouse.Hit.p |
13 | local SetPosition = Part.Position |
14 | while wait() do |
15 | Part.Position = SetPosition |
16 | end |
17 | end ) |