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

Why is this part still moving?

Asked by 10 years ago

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
02local player = game.Players.LocalPlayer
03local mouse = player:GetMouse()
04mouse.Button1Up:connect(function()
05    local Part = Instance.new("Part", Workspace)
06    Part.CanCollide = true
07    Part.Anchored = true
08    Part.Size = Vector3.new(1,10,10)
09    Part.Position = mouse.Hit.p)
10    local Script = game.ServerStorage.Script:Clone()
11    Script.Parent = Part
12end)
1-- Script in ServerStorage
2local Part = script.Parent
3while wait() do
4    if Part.Position.y > 0 then
5        Part.Position = Vector3.new(Part.Position.x, 0, Part.Position.z)
6    end
7end

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?

1 answer

Log in to vote
0
Answered by 10 years ago

Since you have "while wait() do" the part keeps moving?

I would just do this.

01--LocalScript in StarterGear or StarterGui.
02local Player = game.Players.LocalPlayer
03local Mouse = Player:GetMouse()
04 
05Mouse.Button1Down:connect(function() --Your call statement.
06local Part = Instance.new("Part", game.Workspace) --Creates your brick and puts it into game.Workspace.
07Part.Anchored = true
08Part.CanCollide = true
09Part.Transparency = 0
10Part.BrickColor = BrickColor.new("Bright red") --Any color, Just lets you see your brick better.
11Part.Size = Vector3.new(1, 10, 10)
12Part.Position = Mouse.Hit.p
13local SetPosition = Part.Position
14while wait() do
15Part.Position = SetPosition
16end
17end)
0
Tell me if that works! kevinjurden 10 — 10y
0
Nice, that works, It's just a small part of a bigger game, so I just recreated the situation. But it works in my game too. Thank you. damagex443 325 — 10y
0
I thought that putting a while wait loop would make the script become stuck at that point. damagex443 325 — 10y
Ad

Answer this question