You can write your topic however you want, but you need to answer these questions:
What do you want to achieve? I’d like to know how to stop to make the mouse to keep dragging the original object once the function finishes, I’ve been stuck on this for a few days and once you click “Place Nuke” the neon Cylinder isn’t supposed to move.
What is the issue?
What solutions have you tried so far? I’ve tried going on Docs, and Youtube just cannot figure it out!
local camera = game.Workspace.CurrentCamera
local ClickDetector = game.Workspace["Position Part"].ClickDetector
local player = game.Players.LocalPlayer
local FocusPart = game.Workspace.FocusPart
local EndPart = game.Workspace.EndPart
local Mouse = player:GetMouse()
local MousePosition2 = Mouse.Hit.Position
local part = Instance.new("Part")
ClickDetector.MouseClick:Connect(function()
camera.CameraType = "Scriptable"
camera:Interpolate( FocusPart.CFrame, EndPart.CFrame, 2)
wait(2)
Mouse.Button1Down:Connect(function()
part.Name = "NukePos"
part.Shape = Enum.PartType.Cylinder
part.Size = Vector3.new(1.353, 24.337, 42.268)
part.Color = Color3.new(0.254902, 1, 0.976471)
part.Material = Enum.Material.Neon
part.Parent = workspace
part.Anchored = true
part.CanCollide = false
part.Orientation = Vector3.new(0, 0, -90)
while wait(.0001) do
local MousePosition = Mouse.Hit.Position
part.Position = MousePosition
wait()
if workspace:FindFirstChild("PositionLocked") then
break
end
end
end)
Mouse.Button1Up:Connect(function()
local part = workspace:FindFirstChild("NukePos")
if part then
part.Name = "PositionLocked"
part.Position = MousePosition2
end
local NukeGui = player:FindFirstChild("PlayerGui"):FindFirstChild("ScreenGui"):FindFirstChild("PlaceNuke")
if NukeGui then
wait(4)
NukeGui.Visible = true
else
NukeGui.Visible = false
end
NukeGui.MouseButton1Click:Connect(function()
camera.CameraType = "Custom"
local PosLocked = workspace:FindFirstChild("PositionLocked")
if PosLocked then
--I dont know how to make it stop dragging the part
end
end)
end)
end)
You could try checking if the name is not “PositionLocked” in the Mouse.Button1Down event, as whenever the mouse is clicked, it will call that function. By checking if the part is already named “PositionLocked”, you shouldn’t be able to move the part again.
For example:
Mouse.Button1Down:Connect(function()
if part.Name == "PositionLocked" then
return
end
-- do whatever
end
You could also do the same for the Mouse.Button1Up event:
Mouse.Button1Up:Connect(function()
if part.Name == "PositionLocked" then
return
end
-- do whatever
end
Thing is that it keeps still dragging the part to my Mouse Position when I click the Place Nuke even after I returned end, and yeah i actually tried to return end before this it didn’t work
local camera = game.Workspace.CurrentCamera
local ClickDetector = game.Workspace["Position Part"].ClickDetector
local player = game.Players.LocalPlayer
local FocusPart = game.Workspace.FocusPart
local EndPart = game.Workspace.EndPart
local Mouse = player:GetMouse()
local MousePosition2 = Mouse.Hit.Position
local part = Instance.new("Part")
ClickDetector.MouseClick:Connect(function()
camera.CameraType = "Scriptable"
camera:Interpolate( FocusPart.CFrame, EndPart.CFrame, 2)
wait(2)
Mouse.Button1Down:Connect(function()
part.Name = "NukePos"
part.Shape = Enum.PartType.Cylinder
part.Size = Vector3.new(1.353, 24.337, 42.268)
part.Color = Color3.new(0.254902, 1, 0.976471)
part.Material = Enum.Material.Neon
part.Parent = workspace
part.Anchored = true
part.CanCollide = false
part.Orientation = Vector3.new(0, 0, -90)
if part.Name == "PositionLocked" then
return
end
while wait(.0001) do
local MousePosition = Mouse.Hit.Position
part.Position = MousePosition
wait()
if workspace:FindFirstChild("PositionLocked") then
break
end
end
end)
Mouse.Button1Up:Connect(function()
local part = workspace:FindFirstChild("NukePos")
if part then
part.Name = "PositionLocked"
part.Position = MousePosition2
end
local NukeGui = player:FindFirstChild("PlayerGui"):FindFirstChild("ScreenGui"):FindFirstChild("PlaceNuke")
if NukeGui then
wait(4)
NukeGui.Visible = true
else
NukeGui.Visible = false
end
NukeGui.MouseButton1Click:Connect(function()
camera.CameraType = "Custom"
if part.Name == "PositionLocked" then
return
end
end)
end)
end)