Hi! I have a trouble, when i tried to to get position for block that placed with orientation, i got just perfect Y position and i can’t do that block will in floor, how do i can do this:
How to fix that?
Code:
raycastParams.FilterType = Enum.RaycastFilterType.Blacklist
raycastParams.FilterDescendantsInstances = {petpart, char}
raycastParams.IgnoreWater = true
while true do
wait(0.2)
if (char.HumanoidRootPart.Position-petpart.Position).Magnitude >= 8.5 then
local CurrentFloor = workspace:Raycast(petpart.Position+Vector3.new(0,10,0),Vector3.new(0,-50,0), raycastParams)
if CurrentFloor then
print(CurrentFloor.Instance:GetFullName())
local posx = (humpart.Position.X-petpart.Position.X)
local posz = (humpart.Position.Z-petpart.Position.Z)
if posx > 3.5 then posx = 3.5 elseif posx < -3.5 then posx = -3.5 end
if posz > 3.5 then posz = 3.5 elseif posz < -3.5 then posz = -3.5 end
TweenService:Create(petpart, TweenInformation(0.15, "Sine", "Out"), { CFrame = CFrame.new(petpart.Position+Vector3.new(posx/2,1,posz/2))}):Play()
wait(.175)
TweenService:Create(petpart, TweenInformation(0.15, "Sine", "Out"), { CFrame = CFrame.new(petpart.Position.X+posx/2,CurrentFloor.Instance.Position.Y+CurrentFloor.Instance.Size.Y/1.85,petpart.Position.Z+posz/2) * CFrame.Angles(math.rad(CurrentFloor.Instance.Orientation.X), 0,CurrentFloor.Instance.Orientation.Z)}):Play()
else
warn("can't find floor for pet")
end
end
end