-
What do you want to achieve?
For the model to be on top of the map properly -
What is the issue?
It gets stuck under the map for some reason
-
What solutions have you tried so far?
I tried chaning up the Y value, but it didn’t help
RunService.RenderStepped:Connect(function()
if TowerToSpawn then
local result = MouseRaycast({TowerToSpawn})
if result and result.Instance then
local GetRangeBoxTouchingParts = TowerToSpawn.RangeBox:GetTouchingParts()
if result.Instance.Parent.Name == "TowerArea" or result.Instance:GetAttribute("TowerPlaceArea") == true then
CanPlace = true
ColorPlaceholderTower(Color3.new(0,1,0))
else
CanPlace = false
ColorPlaceholderTower(Color3.new(1,0,0))
end
for index, part in ipairs(GetRangeBoxTouchingParts) do
if part.Name == "RangeBox" and part.Parent ~= TowerToSpawn then
CanPlace = false
ColorPlaceholderTower(Color3.new(1,0,0))
end
end
local x = result.Position.X
local y
if TowerToSpawn.Humanoid.RigType == Enum.RigType.R15 then
print("R15")
y = result.Position.Y + TowerToSpawn.Humanoid.HipHeight + (TowerToSpawn.PrimaryPart.Size.Y / 2)
else
print("R6")
y = TowerToSpawn:GetExtentsSize().Y / 2
end
local z = result.Position.Z
local cframe = CFrame.new(x,y,z) * CFrame.Angles(0, math.rad(Rotation), 0)
TowerToSpawn:SetPrimaryPartCFrame(cframe)
PhysicsService:SetPartCollisionGroup(TowerToSpawn.Range,"Tower")
PhysicsService:SetPartCollisionGroup(TowerToSpawn.RangeBox,"TowerBox")
TowerToSpawn.Range.Size = Vector3.new(0.1, TowerToSpawn.Levels[TowerToSpawn.CurrentLevel.Value].Range.Value * 2, TowerToSpawn.Levels[TowerToSpawn.CurrentLevel.Value].Range.Value * 2)
end
end
end)