I’ve got a bug where a player can teleport outside their house if they happen to be sitting in a furniture item. To me this should be impossible as I do raycast to confirm if the player has the floor below them, yet you can still bypass this somehow?
Mouse.Move:Connect(function()
if not IsMoving then return end
-- Do checks to make sure it's being placed within their base
local CheckForFloor = Ray.new(Character.HumanoidRootPart.Position, Vector3.new(0, -50, 0))
local Floor, FloorPos = workspace:FindPartOnRayWithWhitelist(CheckForFloor, {PlayersInterior.Build.InteriorElements})
-- Not players floor/returned nil for some reason
if not Floor then return end
-- Set models parts to not collideable
for i, v in pairs(Model:GetDescendants()) do
if v:IsA('BasePart') or v:IsA('UnionOperation') or v:IsA('MeshPart') then
v.CanCollide = false
end
end
local UnitRay = Camera:ScreenPointToRay(Mouse.X, Mouse.Y, 1)
local NewRay = Ray.new(UnitRay.Origin, UnitRay.Direction * 1000)
local Hit, Pos, Normal = workspace:FindPartOnRayWithIgnoreList(NewRay, {Model, Player.Character, PlayersInterior.Build.Door})
print(Hit, Pos)
local PosX, PosY, PosZ
if OwnsGamepass then
-- Owns the pass, do not lock to grid
if not gridLock then
PosX = Pos.X
PosY = Pos.Y
PosZ = Pos.Z
end
end
if not PosX and not PosY and not PosZ then
-- Does not own gamepass or has advanced placement off
PosX = math.floor((Pos.X / 0.5) + 0.5) * 0.5
PosY = math.floor((Pos.Y / 0.5) + 0.5) * 0.5
PosZ = math.floor((Pos.Z / 0.5) + 0.5) * 0.5
end
local NewPos = Vector3.new(PosX, PosY, PosZ)
Model:SetPrimaryPartCFrame(
CFrame.new(NewPos) * --, NewPos + Normal * 15
CFrame.Angles(0, math.rad(Rotation), 0) *
CFrame.new(0, (Model.PrimaryPart.Size.Y / 2) - 0.25, 0)
)
end)