Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local RunService = game:GetService("RunService")
- local Player = game.Players.LocalPlayer
- local Mouse = Player:GetMouse()
- local Unit = nil
- local RotationX = 0
- local RotationY = 0
- local RotationZ = 0
- Mouse.Button1Down:Connect(function()
- if Unit then
- Unit:Destroy()
- end
- end)
- local function GetTouchingParts(part)
- local connection = part.Touched:Connect(function() end)
- local results = part:GetTouchingParts()
- connection:Disconnect()
- return results
- end
- function doesCollide(unit, obj)
- if unit and obj then
- local results = GetTouchingParts(obj)
- for _, v in pairs(results) do
- if unit:FindFirstChild(v) == false then
- if v == "NoPlacePart" then
- return true
- end
- end
- end
- return false
- else
- return false
- end
- end
- local module = {}
- function module.placeUnitHint()
- script.Parent.Configuration.UnitOrientation.Value = Vector3.new(0, 0, 0)
- if Unit then
- Unit:Destroy()
- end
- Unit = script.Parent.Configuration.UnitChoosed.Value
- Unit = Unit:Clone()
- if Unit:IsA("Model") then
- if Unit:FindFirstChild("Humanoid") then
- else
- for i, v in pairs(Unit:GetChildren()) do
- if v:IsA("Part") or v:IsA("MeshPart") then
- v.Transparency = 0.5
- end
- end
- end
- else
- Unit.Transparency = 0.5
- end
- if Unit:IsA("Model") then
- for i, v in pairs(Unit:GetChildren()) do
- if v:IsA("Part") or v:IsA("MeshPart") then
- v.CanCollide = false
- end
- end
- else
- Unit.CanCollide = false
- end
- if Unit:FindFirstChild("ClickDetector") then
- Unit.ClickDetector.MaxActivationDistance = 0
- end
- Unit.Parent = game.Workspace
- Mouse.TargetFilter = Unit
- script.Parent.Configuration.UnitEditor.Value = true
- RunService.RenderStepped:Connect(function()
- if Unit:IsA("Model") then
- if Unit.PrimaryPart then
- Unit:SetPrimaryPartCFrame(CFrame.new(Mouse.Hit.p))
- Unit:SetPrimaryPartCFrame(CFrame.new(Unit.PrimaryPart.Position.X + Unit.PrimaryPart.Size.X / 2, Unit.PrimaryPart.Position.Y + Unit.PrimaryPart.Size.Y / 2, Unit.PrimaryPart.Position.Z + Unit.PrimaryPart.Size.Z / 2))
- end
- else
- Unit.Position = Mouse.Hit.p
- Unit.Position = Vector3.new(Unit.Position.X + Unit.Size.X / 2, Unit.Position.Y + Unit.Size.Y / 2, Unit.Position.Z + Unit.Size.Z / 2)
- end
- if game.Workspace:FindFirstChild(Player.Name) then
- if game.Workspace[Player.Name]:FindFirstChild("Humanoid") then
- if game.Workspace[Player.Name]:FindFirstChild("HumanoidRootPart") then
- if Unit:IsA("Model") then
- if Unit.PrimaryPart then
- if (game.Workspace[Player.Name].HumanoidRootPart.Position - Unit.PrimaryPart.Position).magnitude < script.Parent.Configuration.UnitPlaceDistance.Value then
- script.Parent.Configuration.UnitPlaceable.Value = true
- else
- script.Parent.Configuration.UnitPlaceable.Value = false
- end
- if doesCollide(Unit, Unit:WaitForChild("Right Leg")) then
- script.Parent.Configuration.UnitPlaceable.Value = false
- else
- script.Parent.Configuration.UnitPlaceable.Value = true
- end
- end
- else
- if (game.Workspace[Player.Name].HumanoidRootPart.Position - Unit.Position).magnitude < script.Parent.Configuration.UnitPlaceDistance.Value then
- Unit.BrickColor = BrickColor.Green()
- script.Parent.Configuration.UnitPlaceable.Value = true
- else
- Unit.BrickColor = BrickColor.Red()
- script.Parent.Configuration.UnitPlaceable.Value = false
- end
- end
- end
- end
- end
- end)
- game:GetService("UserInputService").InputBegan:Connect(function(inputObject, gameProcessedEvent)
- if script.Parent.Configuration.UnitEditor.Value == true then
- if inputObject.KeyCode == Enum.KeyCode.Q then
- RotationX = RotationX + 90
- end
- if inputObject.KeyCode == Enum.KeyCode.E then
- RotationZ = RotationZ + 90
- end
- script.Parent.Configuration.UnitOrientation.Value = Vector3.new(RotationX, RotationY, RotationZ)
- if Unit:IsA("Model") then
- -- Cannot rotate group
- else
- Unit.Orientation = script.Parent.Configuration.UnitOrientation.Value
- end
- end
- end)
- end
- return module
Advertisement
Add Comment
Please, Sign In to add comment