Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local maxRange = 30
- function placeStructure(plrPlacing:Player, structure:Model, cf:CFrame)
- local char = plrPlacing.Character
- if char and char:FindFirstChild("Humanoid") and char.Humanoid.Health > 0 then
- local distance = (char.HumanoidRootPart.Position - cf.Position).Magnitude
- if distance <= maxRange then
- local newStructure = structure:Clone()
- newStructure:PivotTo(cf)
- newStructure.PrimaryPart.Parent = newStructure
- newStructure.PrimaryPart.Name = "HumanoidRootPart"
- local humanoid = Instance.new("Humanoid")
- humanoid.MaxHealth = newStructure.Health.Value
- humanoid.Health = humanoid.MaxHealth
- humanoid.Parent = newStructure
- humanoid.HealthChanged:Connect(function(health)
- if health == 0 then
- newStructure:Destroy()
- end
- end)
- newStructure.Parent = workspace["STRUCTURES"]
- end
- end
- end
- return placeStructure
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement