Player able to move item out of their house when sitting

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)

ezgif.com-video-to-gif (18)

Couldn’t you just check for Humanoid.Sit == true? Alternatively you could look for a SeatWeld in the character or seat - I don’t know which the weld is parented to.

This is a complicated one, this might not work but it’s my initial thoughts:

You could see whether the person who is trying to move something is sitting down or not (the Humanoid property) which would eliminate the above case.

You could also create an attribute in each movable object along the lines of “In Use” and check whether it is set to false (for example, if someone is sitting in the chair then it is In Use).

You could also check whether your ray is coming from the right place, for example if it’s coming out of the feet straight down then it would detect the floor but miss the seat resulting in a false positive.

Hope this helps,
-Tom :slight_smile:

Well I thought of disabling the seat and using like Occupied However I figured that could probs easilyt be bypassed by exploiters and they could move the chair into a player, causing said player to sit and then drag them outside the map

1 Like